Skip to content

Commit 33a2451

Browse files
committed
riscv64: add support for Zicond instructions
1 parent 5787ef9 commit 33a2451

File tree

4 files changed

+20
-3
lines changed

4 files changed

+20
-3
lines changed

riscv64/riscv64asm/tables.go

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

riscv64/riscv64asm/testdata/gnucases.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -384,6 +384,10 @@ a260| ld x1,8(x2)
384384
8624| fld f9,64(x2)
385385
3eb0| fsd f15,32(x2)
386386

387+
# 12.3: "Zicond" Extension for Integer Conditional Operations, Version 1.0.0
388+
b353530e| czero.eqz x7,x6,x5
389+
b373530e| czero.nez x7,x6,x5
390+
387391
# "V" Standard Extension for Vector Operations, Version 1.0
388392

389393
# 31.6: Configuration Setting Instructions

riscv64/riscv64asm/testdata/plan9cases.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,10 @@ b35cbd49| BEXT X27, X26, X25
334334
b3115228| BSET X5, X4, X3
335335
1393f32b| BSETI $63, X7, X6
336336

337+
# 12.3: "Zicond" Extension for Integer Conditional Operations, Version 1.0.0
338+
b353530e| CZEROEQZ X5, X6, X7
339+
b373530e| CZERONEZ X5, X6, X7
340+
337341
# "V" Standard Extension for Vector Operations, Version 1.0
338342

339343
# 31.6: Configuration Setting Instructions

riscv64/riscv64spec/spec.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ var extensions = []string{
3636
"rv_zbb",
3737
"rv_zbs",
3838
"rv_zfh",
39+
"rv_zicond",
3940
"rv_zicsr",
4041
"rv_zifencei",
4142
"rv64_a",
@@ -171,7 +172,7 @@ func main() {
171172

172173
func genInst(words []string) {
173174
op := strings.ToUpper(strings.Replace(words[0], ".", "_", -1))
174-
opstr := fmt.Sprintf("%s:\t\"%s\",", op, strings.ToUpper(words[0]))
175+
opstr := fmt.Sprintf("%-18s %q,", op+":", strings.ToUpper(words[0]))
175176

176177
var value uint32
177178
var mask uint32
@@ -207,7 +208,7 @@ func genInst(words []string) {
207208
// Re-generate the opcode string, opcode value and mask.
208209
for i, suf := range suffix {
209210
aop := op + strings.Replace(suf, ".", "_", -1)
210-
aopstr := fmt.Sprintf("%s:\t\"%s\",", aop, strings.ToUpper(words[0])+suf)
211+
aopstr := fmt.Sprintf("%-18s %q,", aop+":", strings.ToUpper(words[0])+suf)
211212
avalue := value | (uint32(i) << 25)
212213
amask := mask | 0x06000000
213214
ainstFormatComment := "// " + strings.Replace(aop, "_", ".", -1) + " " + strings.Replace(instArgsStr, "arg_", "", -1)
@@ -243,7 +244,7 @@ func genInst(words []string) {
243244
for i := uint32(2); i <= 8; i++ {
244245
segName := strings.ToUpper(fmt.Sprintf("%sSEG%d%s", segOpPrefix, i, segOpSuffix))
245246
segOp := strings.Replace(segName, ".", "_", -1)
246-
segOpStr := fmt.Sprintf("%s:\t\"%s\",", segOp, segName)
247+
segOpStr := fmt.Sprintf("%-18s %q,", segOp+":", segName)
247248
segValue := value | (i-1)<<29
248249
instFormatComment := "// " + segName + " " + strings.Replace(instArgsStr, "arg_", "", -1)
249250
instFormat := fmt.Sprintf("{mask: %#08x, value: %#08x, op: %s, args: argTypeList{%s}},", mask, segValue, segOp, instArgsStr)

0 commit comments

Comments
 (0)