-
Notifications
You must be signed in to change notification settings - Fork 17.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cmd/asm,cmd/internal/obj: initial support for riscv64 assembler
Provide the initial framework for the riscv64 assembler. For now this only supports raw WORD instructions, but at least allows for basic testing. Additional functionality will be added in separate changes. Based on the riscv-go port. Updates #27532 Change-Id: I181ffb2d37a34764a3e91eded177d13a89c69f9a Reviewed-on: https://go-review.googlesource.com/c/go/+/194117 Reviewed-by: Cherry Zhang <cherryyz@google.com>
- Loading branch information
Showing
8 changed files
with
364 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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 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 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,11 @@ | ||
// Copyright 2019 The Go Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style | ||
// license that can be found in the LICENSE file. | ||
|
||
#include "../../../../../runtime/textflag.h" | ||
|
||
TEXT asmtest(SB),DUPOK|NOSPLIT,$0 | ||
|
||
// Arbitrary bytes (entered in little-endian mode) | ||
WORD $0x12345678 // WORD $305419896 // 78563412 | ||
WORD $0x9abcdef0 // WORD $2596069104 // f0debc9a |
This file contains 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains 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 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 @@ | ||
// Copyright 2019 The Go Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style | ||
// license that can be found in the LICENSE file. | ||
|
||
package riscv | ||
|
||
import ( | ||
"fmt" | ||
|
||
"cmd/internal/obj" | ||
) | ||
|
||
func init() { | ||
obj.RegisterRegister(obj.RBaseRISCV, REG_END, regName) | ||
obj.RegisterOpcode(obj.ABaseRISCV, Anames) | ||
} | ||
|
||
func regName(r int) string { | ||
switch { | ||
case r == 0: | ||
return "NONE" | ||
case r == REG_G: | ||
return "g" | ||
case r == REG_SP: | ||
return "SP" | ||
case REG_X0 <= r && r <= REG_X31: | ||
return fmt.Sprintf("X%d", r-REG_X0) | ||
case REG_F0 <= r && r <= REG_F31: | ||
return fmt.Sprintf("F%d", r-REG_F0) | ||
default: | ||
return fmt.Sprintf("Rgok(%d)", r-obj.RBaseRISCV) | ||
} | ||
} |
Oops, something went wrong.