| 1 | package passscip-go gomod github.com/mmcloughlin/avo . `github.com/mmcloughlin/avo/pass`/ |
| 2 | |
| 3 | import ( |
| 4 | "stringsscip-go gomod github.com/golang/go/src go1.18 strings/" |
| 5 | "testingscip-go gomod github.com/golang/go/src go1.18 testing/" |
| 6 | |
| 7 | "github.com/mmcloughlin/avo/irscip-go gomod github.com/mmcloughlin/avo . `github.com/mmcloughlin/avo/ir`/" |
| 8 | "github.com/mmcloughlin/avo/operandscip-go gomod github.com/mmcloughlin/avo . `github.com/mmcloughlin/avo/operand`/" |
| 9 | "github.com/mmcloughlin/avo/regscip-go gomod github.com/mmcloughlin/avo . `github.com/mmcloughlin/avo/reg`/" |
| 10 | ) |
| 11 | |
| 12 | func TestVerifyMemOperandsscip-go gomod github.com/mmcloughlin/avo . `github.com/mmcloughlin/avo/pass`/TestVerifyMemOperands().(t *testingscip-go gomod github.com/golang/go/src go1.18 testing/.Tscip-go gomod github.com/golang/go/src go1.18 testing/T#) { |
| 13 | i := &irscip-go gomod github.com/mmcloughlin/avo . `github.com/mmcloughlin/avo/ir`/.Instructionscip-go gomod github.com/mmcloughlin/avo . `github.com/mmcloughlin/avo/ir`/Instruction#{ |
| 14 | Operandsscip-go gomod github.com/mmcloughlin/avo . `github.com/mmcloughlin/avo/ir`/Instruction#Operands.: []operandscip-go gomod github.com/mmcloughlin/avo . `github.com/mmcloughlin/avo/operand`/.Opscip-go gomod github.com/mmcloughlin/avo . `github.com/mmcloughlin/avo/operand`/Op#{ |
| 15 | regscip-go gomod github.com/mmcloughlin/avo . `github.com/mmcloughlin/avo/reg`/.RAXscip-go gomod github.com/mmcloughlin/avo . `github.com/mmcloughlin/avo/reg`/RAX., |
| 16 | operandscip-go gomod github.com/mmcloughlin/avo . `github.com/mmcloughlin/avo/operand`/.Memscip-go gomod github.com/mmcloughlin/avo . `github.com/mmcloughlin/avo/operand`/Mem#{ |
| 17 | Basescip-go gomod github.com/mmcloughlin/avo . `github.com/mmcloughlin/avo/operand`/Mem#Base.: regscip-go gomod github.com/mmcloughlin/avo . `github.com/mmcloughlin/avo/reg`/.R10scip-go gomod github.com/mmcloughlin/avo . `github.com/mmcloughlin/avo/reg`/R10., |
| 18 | Dispscip-go gomod github.com/mmcloughlin/avo . `github.com/mmcloughlin/avo/operand`/Mem#Disp.: 42, |
| 19 | }, |
| 20 | }, |
| 21 | } |
| 22 | if err := VerifyMemOperandsscip-go gomod github.com/mmcloughlin/avo . `github.com/mmcloughlin/avo/pass`/VerifyMemOperands().(i); err != nil { |
| 23 | t.Fatalscip-go gomod github.com/golang/go/src go1.18 testing/common#Fatal().(err) |
| 24 | } |
| 25 | } |
| 26 | |
| 27 | func TestVerifyMemOperandsErrorsscip-go gomod github.com/mmcloughlin/avo . `github.com/mmcloughlin/avo/pass`/TestVerifyMemOperandsErrors().(t *testingscip-go gomod github.com/golang/go/src go1.18 testing/.Tscip-go gomod github.com/golang/go/src go1.18 testing/T#) { |
| 28 | cases := []struct { |
| 29 | Operands []operandscip-go gomod github.com/mmcloughlin/avo . `github.com/mmcloughlin/avo/operand`/.Opscip-go gomod github.com/mmcloughlin/avo . `github.com/mmcloughlin/avo/operand`/Op# |
| 30 | ErrorSubstring string |
| 31 | }{ |
| 32 | { |
| 33 | Operands: []operandscip-go gomod github.com/mmcloughlin/avo . `github.com/mmcloughlin/avo/operand`/.Opscip-go gomod github.com/mmcloughlin/avo . `github.com/mmcloughlin/avo/operand`/Op#{ |
| 34 | regscip-go gomod github.com/mmcloughlin/avo . `github.com/mmcloughlin/avo/reg`/.RAXscip-go gomod github.com/mmcloughlin/avo . `github.com/mmcloughlin/avo/reg`/RAX., |
| 35 | operandscip-go gomod github.com/mmcloughlin/avo . `github.com/mmcloughlin/avo/operand`/.Memscip-go gomod github.com/mmcloughlin/avo . `github.com/mmcloughlin/avo/operand`/Mem#{ |
| 36 | Dispscip-go gomod github.com/mmcloughlin/avo . `github.com/mmcloughlin/avo/operand`/Mem#Disp.: 42, |
| 37 | }, |
| 38 | }, |
| 39 | ErrorSubstring: "missing base", |
| 40 | }, |
| 41 | { |
| 42 | Operands: []operandscip-go gomod github.com/mmcloughlin/avo . `github.com/mmcloughlin/avo/operand`/.Opscip-go gomod github.com/mmcloughlin/avo . `github.com/mmcloughlin/avo/operand`/Op#{ |
| 43 | operandscip-go gomod github.com/mmcloughlin/avo . `github.com/mmcloughlin/avo/operand`/.Memscip-go gomod github.com/mmcloughlin/avo . `github.com/mmcloughlin/avo/operand`/Mem#{ |
| 44 | Basescip-go gomod github.com/mmcloughlin/avo . `github.com/mmcloughlin/avo/operand`/Mem#Base.: regscip-go gomod github.com/mmcloughlin/avo . `github.com/mmcloughlin/avo/reg`/.EBXscip-go gomod github.com/mmcloughlin/avo . `github.com/mmcloughlin/avo/reg`/EBX., |
| 45 | Indexscip-go gomod github.com/mmcloughlin/avo . `github.com/mmcloughlin/avo/operand`/Mem#Index.: regscip-go gomod github.com/mmcloughlin/avo . `github.com/mmcloughlin/avo/reg`/.R9Lscip-go gomod github.com/mmcloughlin/avo . `github.com/mmcloughlin/avo/reg`/R9L., |
| 46 | }, |
| 47 | regscip-go gomod github.com/mmcloughlin/avo . `github.com/mmcloughlin/avo/reg`/.ECXscip-go gomod github.com/mmcloughlin/avo . `github.com/mmcloughlin/avo/reg`/ECX., |
| 48 | }, |
| 49 | ErrorSubstring: "index register with scale 0", |
| 50 | }, |
| 51 | } |
| 52 | for _, c := range cases { |
| 53 | i := &irscip-go gomod github.com/mmcloughlin/avo . `github.com/mmcloughlin/avo/ir`/.Instructionscip-go gomod github.com/mmcloughlin/avo . `github.com/mmcloughlin/avo/ir`/Instruction#{Operandsscip-go gomod github.com/mmcloughlin/avo . `github.com/mmcloughlin/avo/ir`/Instruction#Operands.: c.Operands} |
| 54 | if err := VerifyMemOperandsscip-go gomod github.com/mmcloughlin/avo . `github.com/mmcloughlin/avo/pass`/VerifyMemOperands().(i); err == nil || !stringsscip-go gomod github.com/golang/go/src go1.18 strings/.Containsscip-go gomod github.com/golang/go/src go1.18 strings/Contains().(err.Error(), c.ErrorSubstring) { |
| 55 | t.Errorfscip-go gomod github.com/golang/go/src go1.18 testing/common#Errorf().("got error %v; expected error to contain %q", err, c.ErrorSubstring) |
| 56 | } |
| 57 | } |
| 58 | } |