Lines Matching refs:self
41 def __init__(self, operand_list):
42 self.operand_list = operand_list
44 def __iter__(self):
45 return iter(self.operand_list)
47 def unwrap(self):
62 return itertools.chain(*self.operand_list)
64 def ExcludeVariants(self, type_name, variant_to_exclude):
70 self)
77 def GetNames(self):
81 return [operand.name for operand in self.unwrap()]
94 def __init__(self, inputs):
95 self.inputs = inputs
97 def __iter__(self):
98 return iter(self.inputs)
100 def GetNames(self):
104 return [input.name for input in self]
131 # `self.operand_filter`.
137 def __init__(self, name, seed, operand_names, input_names, operand_filter,
139 self.name = name
140 self.seed = seed
141 self.operand_names = operand_names
142 self.input_names = input_names
143 self.operand_filter = operand_filter
144 self.input_filter = input_filter
145 self.operand_limit = operand_limit
146 self.input_limit = input_limit
147 self.it_condition = it_condition
149 def GenerateOperands(self, operand_types):
156 name in the `self.operand_names` list.
158 Additionally, we use the Python expression in `self.operand_filter` to
166 # operand's name is not in `self.operand_names`, then we restrict the list
178 if operand_type.name in self.operand_names
184 expression=self.operand_filter)
185 filter_lambda = eval(lambda_string, self.operand_filter_runtime)
213 "true" if self.it_condition else "false",
215 self.it_condition.format(**dict(operands)) if self.it_condition else "al"
245 if self.operand_limit is None:
249 random.seed(self.seed)
250 return random.sample(result, self.operand_limit)
252 def GenerateInputs(self, input_types):
259 in the `self.input_names` list.
261 Additionally, we use the Python expression in `self.input_filter` to filter
269 # name is not in `self.input_names`, then we restrict the list to the
273 if input_type.name in self.input_names else [input_type.default]
278 expression=self.input_filter)
287 if self.input_limit is None:
291 random.seed(self.seed)
292 return random.sample(result, self.input_limit)
312 def __init__(self, test_name, test_isa, test_type, mnemonics, operands,
314 self.test_name = test_name
315 self.test_isa = test_isa
316 self.test_type = test_type
317 self.mnemonics = mnemonics
318 self.inputs = inputs
319 self.test_cases = test_cases
322 if self.test_type == "simulator":
325 self.operands = deepcopy(operands)
326 self.operands.ExcludeVariants("Register", ["r13", "r15"])
328 self.operands = operands
330 def MnemonicToMethodName(self, mnemonic):
331 if self.test_type in ["simulator", "macro-assembler"]:
339 def InstructionListDeclaration(self):
351 "M({}) \\\n".format(self.MnemonicToMethodName(mnemonic))
352 for mnemonic in self.mnemonics
355 def OperandDeclarations(self):
364 return "".join([operand.Declare() for operand in self.operands])
366 def InputDeclarations(self):
375 return "".join([input.Declare() for input in self.inputs])
377 def InputDefinitions(self):
388 for input in test_input.GenerateInputs(self.inputs)
394 return "\n".join(map(InputDefinition, self.test_cases))
396 def TestCaseDefinitions(self):
442 for operand, _, _ in test_case.GenerateOperands(self.operands)
459 in test_case.GenerateOperands(self.operands)
471 for operand, _, _ in test_case.GenerateOperands(self.operands)
475 if self.test_type == "simulator":
476 return ",\n".join(map(SimulatorTestCaseDefinition, self.test_cases))
477 elif self.test_type == "assembler":
478 return ",\n".join(map(AssemblerTestCaseDefinition, self.test_cases))
479 elif self.test_type == "macro-assembler":
480 return ",\n".join(map(MacroAssemblerTestCaseDefinition, self.test_cases))
481 elif self.test_type == "assembler-negative":
482 return ",\n".join(map(MacroAssemblerTestCaseDefinition, self.test_cases))
484 raise Exception("Unrecognized test type \"{}\".".format(self.test_type))
486 def IncludeTraceFiles(self):
494 operands = "-".join(self.operands.GetNames())
496 "#include \"aarch32/traces/" + self.GetTraceFileName(mnemonic) + "\"\n"
497 for mnemonic in self.mnemonics
500 def MacroAssemblerMethodArgs(self):
508 for operand in self.operands
511 def MacroAssemblerSetISA(self):
515 if self.test_isa == "t32":
520 def CodeInstantiateOperands(self):
528 code = "".join([operand.Instantiate() for operand in self.operands])
529 if self.test_type in ["simulator", "macro-assembler"]:
539 for operand in self.operands.unwrap()
545 def CodePrologue(self):
553 return "".join([input.Prologue() for input in self.inputs])
555 def CodeEpilogue(self):
563 return "".join([input.Epilogue() for input in self.inputs])
565 def CodeParameterList(self):
573 for operand in self.operands
576 def TracePrintOutputs(self):
587 [input.PrintOutput() for input in self.inputs])
590 def CheckInstantiateResults(self):
598 return "".join([input.InstantiateResult() for input in self.inputs])
600 def CheckInstantiateInputs(self):
608 return "".join([input.InstantiateInput("_input") for input in self.inputs])
610 def CheckInstantiateReferences(self):
618 return "".join([input.InstantiateReference("_ref") for input in self.inputs])
620 def CheckResultsAgainstReferences(self):
626 return " || ".join([input.Compare("", "!=", "_ref") for input in self.inputs])
628 def CheckPrintInput(self):
639 [input.PrintInput("_input") for input in self.inputs])
641 def CheckPrintExpected(self):
652 [input.PrintInput("_ref") for input in self.inputs])
654 def CheckPrintFound(self):
665 [input.PrintInput("") for input in self.inputs])
667 def TestName(self):
673 return self.test_type.replace("-", "_").upper() + "_" + \
674 self.test_name.replace("-", "_").upper()
676 def TestISA(self):
677 return self.test_isa.upper()
679 def GetTraceFileName(self, mnemonic):
683 return self.test_type + "-" + self.test_name + "-" + \
684 mnemonic.lower() + "-" + self.test_isa + ".h"
686 def WriteEmptyTraces(self, output_directory):
690 for mnemonic in self.mnemonics:
692 if self.test_type in ["macro-assembler", "assembler-negative"]: continue
694 with open(os.path.join(output_directory, self.GetTraceFileName(mnemonic)),
697 f.write(code.format(self.MnemonicToMethodName(mnemonic)))
699 def GetIsaGuard(self):
703 if self.test_isa == 'a32':
706 assert self.test_isa == 't32'