-
Notifications
You must be signed in to change notification settings - Fork 3
Add ARM lowering coverage across stdlib asm corpus #10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
8617d1c
Add initial ARM parser and translation support
cpunion f0734d5
Add ARM CFG lowering for branch-heavy stdlib asm
cpunion 676b556
Complete ARM stdlib linux/arm lowering coverage
cpunion 30573e8
Finish ARM cross-platform scan coverage
cpunion aacdda4
Expand CI coverage for ARM and CLI modules
cpunion 7fd3812
Fix ARM CI regressions
cpunion 928eef5
Harden ARM CI gates
cpunion afb4b08
Address ARM review feedback
cpunion 02fcf2b
Limit symbolic immediate rejection to ARM
cpunion File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| package plan9asm | ||
|
|
||
| import ( | ||
| "strings" | ||
| "testing" | ||
| ) | ||
|
|
||
| func TestTranslateARMLdrexStrex(t *testing.T) { | ||
| file, err := Parse(ArchARM, `TEXT ·cas(SB),NOSPLIT,$0-0 | ||
| LDREX (R1), R0 | ||
| STREX R3, (R1), R0 | ||
| RET | ||
| `) | ||
| if err != nil { | ||
| t.Fatalf("Parse() error = %v", err) | ||
| } | ||
| ll, err := Translate(file, Options{ | ||
| TargetTriple: "armv7-unknown-linux-gnueabihf", | ||
| Goarch: "arm", | ||
| ResolveSym: func(sym string) string { return "example." + strings.TrimPrefix(sym, "·") }, | ||
| Sigs: map[string]FuncSig{ | ||
| "example.cas": {Name: "example.cas", Ret: Void}, | ||
| }, | ||
| }) | ||
| if err != nil { | ||
| t.Fatalf("Translate() error = %v", err) | ||
| } | ||
| for _, want := range []string{"load atomic i32", "cmpxchg ptr", "%exclusive_valid"} { | ||
| if !strings.Contains(ll, want) { | ||
| t.Fatalf("missing %q in output:\n%s", want, ll) | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,112 @@ | ||
| package plan9asm | ||
|
|
||
| import ( | ||
| "strings" | ||
| "testing" | ||
| ) | ||
|
|
||
| func TestTranslateARMMOVMPushPop(t *testing.T) { | ||
| file, err := Parse(ArchARM, `TEXT ·f(SB),NOSPLIT,$0-0 | ||
| MOVM.DB.W [R0,R1], (R13) | ||
| MOVM.IA.W (R13), [R0,R1] | ||
| RET | ||
| `) | ||
| if err != nil { | ||
| t.Fatalf("Parse() error = %v", err) | ||
| } | ||
| ll, err := Translate(file, Options{ | ||
| TargetTriple: "armv7-unknown-linux-gnueabihf", | ||
| Goarch: "arm", | ||
| ResolveSym: func(sym string) string { return "example." + strings.TrimPrefix(sym, "·") }, | ||
| Sigs: map[string]FuncSig{ | ||
| "example.f": {Name: "example.f", Ret: Void}, | ||
| }, | ||
| }) | ||
| if err != nil { | ||
| t.Fatalf("Translate() error = %v", err) | ||
| } | ||
| for _, want := range []string{"store i32", "load i32", "%reg_R13"} { | ||
| if !strings.Contains(ll, want) { | ||
| t.Fatalf("missing %q in output:\n%s", want, ll) | ||
| } | ||
| } | ||
| } | ||
|
|
||
| func TestTranslateARMSWI(t *testing.T) { | ||
| file, err := Parse(ArchARM, `TEXT ·raw(SB),NOSPLIT,$0-0 | ||
| MOVW $1, R7 | ||
| MOVW $2, R0 | ||
| SWI $0 | ||
| RET | ||
| `) | ||
| if err != nil { | ||
| t.Fatalf("Parse() error = %v", err) | ||
| } | ||
| ll, err := Translate(file, Options{ | ||
| TargetTriple: "armv7-unknown-linux-gnueabihf", | ||
| Goarch: "arm", | ||
| ResolveSym: func(sym string) string { return "example." + strings.TrimPrefix(sym, "·") }, | ||
| Sigs: map[string]FuncSig{ | ||
| "example.raw": {Name: "example.raw", Ret: I32}, | ||
| }, | ||
| }) | ||
| if err != nil { | ||
| t.Fatalf("Translate() error = %v", err) | ||
| } | ||
| if !strings.Contains(ll, "call i64 @syscall(") { | ||
| t.Fatalf("missing syscall call in output:\n%s", ll) | ||
| } | ||
| } | ||
|
|
||
| func TestTranslateARMMOVDFloatSaveRestore(t *testing.T) { | ||
| file, err := Parse(ArchARM, `TEXT ·f(SB),NOSPLIT,$0-0 | ||
| MOVD F0, 8(R13) | ||
| MOVD 8(R13), F1 | ||
| RET | ||
| `) | ||
| if err != nil { | ||
| t.Fatalf("Parse() error = %v", err) | ||
| } | ||
| ll, err := Translate(file, Options{ | ||
| TargetTriple: "armv7-unknown-linux-gnueabihf", | ||
| Goarch: "arm", | ||
| ResolveSym: func(sym string) string { return "example." + strings.TrimPrefix(sym, "·") }, | ||
| Sigs: map[string]FuncSig{ | ||
| "example.f": {Name: "example.f", Ret: Void}, | ||
| }, | ||
| }) | ||
| if err != nil { | ||
| t.Fatalf("Translate() error = %v", err) | ||
| } | ||
| for _, want := range []string{"%freg_F0 = alloca i64", "store i64", "load i64"} { | ||
| if !strings.Contains(ll, want) { | ||
| t.Fatalf("missing %q in output:\n%s", want, ll) | ||
| } | ||
| } | ||
| } | ||
|
|
||
| func TestTranslateARMMullu(t *testing.T) { | ||
| file, err := Parse(ArchARM, `TEXT ·mul(SB),NOSPLIT,$0-0 | ||
| MULLU R1, R0, (R2, R3) | ||
| RET | ||
| `) | ||
| if err != nil { | ||
| t.Fatalf("Parse() error = %v", err) | ||
| } | ||
| ll, err := Translate(file, Options{ | ||
| TargetTriple: "armv7-unknown-linux-gnueabihf", | ||
| Goarch: "arm", | ||
| ResolveSym: func(sym string) string { return "example." + strings.TrimPrefix(sym, "·") }, | ||
| Sigs: map[string]FuncSig{ | ||
| "example.mul": {Name: "example.mul", Ret: Void}, | ||
| }, | ||
| }) | ||
| if err != nil { | ||
| t.Fatalf("Translate() error = %v", err) | ||
| } | ||
| for _, want := range []string{"mul i64", "lshr i64", "store i32"} { | ||
| if !strings.Contains(ll, want) { | ||
| t.Fatalf("missing %q in output:\n%s", want, ll) | ||
| } | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.