diff options
author | Koakuma <koachan@protonmail.com> | 2024-06-09 09:58:46 +0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-06-09 09:58:46 +0700 |
commit | f20d8b9dcb07188813f52b9be308325f74154196 (patch) | |
tree | 3468e93e1ed3f2db9e07e2feb41b0f9c5e9b9de5 | |
parent | dcb71c06c7b059e313f22e46bc9c41343a03f1eb (diff) | |
download | llvm-f20d8b9dcb07188813f52b9be308325f74154196.zip llvm-f20d8b9dcb07188813f52b9be308325f74154196.tar.gz llvm-f20d8b9dcb07188813f52b9be308325f74154196.tar.bz2 |
[SPARC][IAS] Add GNU extension for `addc`
Transform `addc imm, %rs, %rd` into `addc %rs, imm, %rd`.
This is used in some GNU and Linux code.
Reviewers: s-barannikov, rorth, jrtc27, brad0
Reviewed By: s-barannikov
Pull Request: https://github.com/llvm/llvm-project/pull/94245
-rw-r--r-- | llvm/lib/Target/Sparc/SparcInstrAliases.td | 11 | ||||
-rw-r--r-- | llvm/test/MC/Sparc/sparcv9-instructions.s | 10 |
2 files changed, 18 insertions, 3 deletions
diff --git a/llvm/lib/Target/Sparc/SparcInstrAliases.td b/llvm/lib/Target/Sparc/SparcInstrAliases.td index db4c05c..2b92445 100644 --- a/llvm/lib/Target/Sparc/SparcInstrAliases.td +++ b/llvm/lib/Target/Sparc/SparcInstrAliases.td @@ -560,11 +560,16 @@ def : InstAlias<"mov $simm13, %tbr", (WRTBRri G0, simm13Op:$simm13), 0>; // End of Section A.3 -// or imm, reg, rd -> or reg, imm, rd -// Nonstandard GNU extension. -let EmitPriority = 0 in + +// Nonstandard GNU extensions. +let EmitPriority = 0 in { + // or imm, reg, rd -> or reg, imm, rd def : InstAlias<"or $simm13, $rs1, $rd", (ORri IntRegs:$rd, IntRegs:$rs1, simm13Op:$simm13)>; + // addc/addx imm, reg, rd -> or reg, imm, rd + def : InstAlias<"addx $simm13, $rs1, $rd", (ADDCri IntRegs:$rd, IntRegs:$rs1, simm13Op:$simm13)>; +} + // wr reg_or_imm, specialreg -> wr %g0, reg_or_imm, specialreg // (aka: omit the first arg when it's g0. This is not in the manual, but is // supported by gnu and solaris as) diff --git a/llvm/test/MC/Sparc/sparcv9-instructions.s b/llvm/test/MC/Sparc/sparcv9-instructions.s index 0ca2e50..b947243 100644 --- a/llvm/test/MC/Sparc/sparcv9-instructions.s +++ b/llvm/test/MC/Sparc/sparcv9-instructions.s @@ -7,6 +7,16 @@ addc %g2, %g1, %g3 ! V8: error: invalid instruction mnemonic + ! V8-NEXT: addc %g2, 1, %g3 + ! V9: addx %g2, 1, %g3 ! encoding: [0x86,0x40,0xa0,0x01] + addc %g2, 1, %g3 + + ! V8: error: invalid instruction mnemonic + ! V8-NEXT: addc 1, %g2, %g3 + ! V9: addx %g2, 1, %g3 ! encoding: [0x86,0x40,0xa0,0x01] + addc 1, %g2, %g3 + + ! V8: error: invalid instruction mnemonic ! V8-NEXT: addccc %g1, %g2, %g3 ! V9: addxcc %g1, %g2, %g3 ! encoding: [0x86,0xc0,0x40,0x02] addccc %g1, %g2, %g3 |