aboutsummaryrefslogtreecommitdiff
path: root/parse_opcodes
diff options
context:
space:
mode:
authorJoel Sing <joel@sing.id.au>2021-01-23 08:57:00 +1100
committerGitHub <noreply@github.com>2021-01-22 13:57:00 -0800
commitd2ef643520da334443a9c99fd107a9487ad7c4b9 (patch)
treedbe06008a1e8cf1657d89a76a0fa02067e633506 /parse_opcodes
parent0fb56dc2857afe66f95295516e0c499648203486 (diff)
downloadriscv-opcodes-d2ef643520da334443a9c99fd107a9487ad7c4b9.zip
riscv-opcodes-d2ef643520da334443a9c99fd107a9487ad7c4b9.tar.gz
riscv-opcodes-d2ef643520da334443a9c99fd107a9487ad7c4b9.tar.bz2
Update Go instruction encoding generation (#34)
Remove the 'ok' value since this is redundant - an invalid instruction can already be identified by a nil return value. Also, include the script flags in the 'DO NOT EDIT' header.
Diffstat (limited to 'parse_opcodes')
-rwxr-xr-xparse_opcodes8
1 files changed, 4 insertions, 4 deletions
diff --git a/parse_opcodes b/parse_opcodes
index 6002b01..1118e18 100755
--- a/parse_opcodes
+++ b/parse_opcodes
@@ -994,10 +994,10 @@ def print_go_insn(name):
rs2 = yank(m, 20, 5)
csr = yank(m, 20, 12)
funct7 = yank(m, 25, 7)
- print('\t\treturn &inst{0x%x, 0x%x, 0x%x, %d, 0x%x}, true' % (opcode, funct3, rs2, signed(csr, 12), funct7))
+ print('\t\treturn &inst{0x%x, 0x%x, 0x%x, %d, 0x%x}' % (opcode, funct3, rs2, signed(csr, 12), funct7))
def make_go():
- print('// Code generated by parse_opcodes; DO NOT EDIT.')
+ print('// Code generated by parse_opcodes -go; DO NOT EDIT.')
print()
print('package riscv')
print()
@@ -1011,12 +1011,12 @@ def make_go():
print('\tfunct7 uint32')
print('}')
print()
- print('func encode(a obj.As) (i *inst, ok bool) {')
+ print('func encode(a obj.As) *inst {')
print('\tswitch a {')
for name in namelist:
print_go_insn(name)
print('\t}')
- print('\treturn nil, false')
+ print('\treturn nil')
print('}')
def make_rust():