| 1 |
// Scaffolding for testing arm64 Ion code generation patterns . See |
| 2 |
// codegen-x64-test.js in this directory for more information. |
| 3 |
|
| 4 |
load(libdir + "codegen-test-common.js"); |
| 5 |
|
| 6 |
// End of prologue |
| 7 |
var arm64_prefix = ` |
| 8 |
910003fd mov x29, sp |
| 9 |
910003fc mov x28, sp( |
| 10 |
f9000bb7 str x23, \\[x29, #16\\])? |
| 11 |
`; |
| 12 |
|
| 13 |
// Start of epilogue |
| 14 |
var arm64_suffix = ` |
| 15 |
f94007fe ldr x30, \\[sp, #8\\] |
| 16 |
f94003fd ldr x29, \\[sp\\] |
| 17 |
`; |
| 18 |
|
| 19 |
// For when nothing else applies: `module_text` is the complete source text of |
| 20 |
// the module, `export_name` is the name of the function to be tested, |
| 21 |
// `expected` is the non-preprocessed pattern, and options is an options bag, |
| 22 |
// described above. |
| 23 |
function codegenTestARM64_adhoc(module_text, export_name, expected, options = {}) { |
| 24 |
assertEq(hasDisassembler(), true); |
| 25 |
|
| 26 |
let ins = wasmEvalText(module_text, {}, options.features); |
| 27 |
if (options.instanceBox) |
| 28 |
options.instanceBox.value = ins; |
| 29 |
let output = wasmDis(ins.exports[export_name], {tier:"ion", asString:true}); |
| 30 |
|
| 31 |
const expected_initial = expected; |
| 32 |
if (!options.no_prefix) |
| 33 |
expected = arm64_prefix + '\n' + expected; |
| 34 |
if (!options.no_suffix) |
| 35 |
expected = expected + '\n' + arm64_suffix; |
| 36 |
expected = fixlines(expected); |
| 37 |
|
| 38 |
const output_matches_expected = output.match(new RegExp(expected)) != null; |
| 39 |
if (!output_matches_expected) { |
| 40 |
print("---- codegen-arm64-test.js: TEST FAILED ----"); |
| 41 |
} |
| 42 |
if (options.log && output_matches_expected) { |
| 43 |
print("---- codegen-arm64-test.js: TEST PASSED ----"); |
| 44 |
} |
| 45 |
if (options.log || !output_matches_expected) { |
| 46 |
print("---- module text"); |
| 47 |
print(module_text); |
| 48 |
print("---- actual"); |
| 49 |
print(output); |
| 50 |
print("---- expected (initial)"); |
| 51 |
print(expected_initial); |
| 52 |
print("---- expected (as used)"); |
| 53 |
print(expected); |
| 54 |
print("----"); |
| 55 |
} |
| 56 |
|
| 57 |
assertEq(output_matches_expected, true); |
| 58 |
} |
| 59 |
|