Skip to content

Commit 3ed4b0b

Browse files
[NVPTX] Emit prmt selection value in hex (llvm#115049)
1 parent 768b0b4 commit 3ed4b0b

File tree

6 files changed

+111
-90
lines changed

6 files changed

+111
-90
lines changed

llvm/lib/Target/NVPTX/MCTargetDesc/NVPTXInstPrinter.cpp

+6
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,12 @@ void NVPTXInstPrinter::printOffseti32imm(const MCInst *MI, int OpNum,
373373
}
374374
}
375375

376+
void NVPTXInstPrinter::printHexu32imm(const MCInst *MI, int OpNum,
377+
raw_ostream &O, const char *Modifier) {
378+
int64_t Imm = MI->getOperand(OpNum).getImm();
379+
O << formatHex(Imm) << "U";
380+
}
381+
376382
void NVPTXInstPrinter::printProtoIdent(const MCInst *MI, int OpNum,
377383
raw_ostream &O, const char *Modifier) {
378384
const MCOperand &Op = MI->getOperand(OpNum);

llvm/lib/Target/NVPTX/MCTargetDesc/NVPTXInstPrinter.h

+2
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ class NVPTXInstPrinter : public MCInstPrinter {
4848
raw_ostream &O, const char *Modifier = nullptr);
4949
void printOffseti32imm(const MCInst *MI, int OpNum, raw_ostream &O,
5050
const char *Modifier = nullptr);
51+
void printHexu32imm(const MCInst *MI, int OpNum, raw_ostream &O,
52+
const char *Modifier = nullptr);
5153
void printProtoIdent(const MCInst *MI, int OpNum,
5254
raw_ostream &O, const char *Modifier = nullptr);
5355
void printPrmtMode(const MCInst *MI, int OpNum, raw_ostream &O,

llvm/lib/Target/NVPTX/NVPTXInstrInfo.td

+6-2
Original file line numberDiff line numberDiff line change
@@ -1740,6 +1740,10 @@ multiclass BFI<string Instr, ValueType T, RegisterClass RC, Operand ImmCls> {
17401740
[(set (T RC:$f), (bfi (T imm:$a), (T RC:$b), (i32 imm:$c), (i32 imm:$d)))]>;
17411741
}
17421742

1743+
def Hexu32imm : Operand<i32> {
1744+
let PrintMethod = "printHexu32imm";
1745+
}
1746+
17431747
multiclass PRMT<ValueType T, RegisterClass RC> {
17441748
def rrr
17451749
: NVPTXInst<(outs RC:$d),
@@ -1748,12 +1752,12 @@ multiclass PRMT<ValueType T, RegisterClass RC> {
17481752
[(set (T RC:$d), (prmt (T RC:$a), (T RC:$b), (i32 Int32Regs:$c), imm:$mode))]>;
17491753
def rri
17501754
: NVPTXInst<(outs RC:$d),
1751-
(ins RC:$a, Int32Regs:$b, i32imm:$c, PrmtMode:$mode),
1755+
(ins RC:$a, Int32Regs:$b, Hexu32imm:$c, PrmtMode:$mode),
17521756
!strconcat("prmt.b32${mode}", " \t$d, $a, $b, $c;"),
17531757
[(set (T RC:$d), (prmt (T RC:$a), (T RC:$b), (i32 imm:$c), imm:$mode))]>;
17541758
def rii
17551759
: NVPTXInst<(outs RC:$d),
1756-
(ins RC:$a, i32imm:$b, i32imm:$c, PrmtMode:$mode),
1760+
(ins RC:$a, i32imm:$b, Hexu32imm:$c, PrmtMode:$mode),
17571761
!strconcat("prmt.b32${mode}", " \t$d, $a, $b, $c;"),
17581762
[(set (T RC:$d), (prmt (T RC:$a), (T imm:$b), (i32 imm:$c), imm:$mode))]>;
17591763
}

0 commit comments

Comments
 (0)