Skip to content

Commit 39b6340

Browse files
shiltiantomtor
authored andcommitted
[AMDGPU][AsmParser] Support true16 register suffix for valid register range (llvm#143997)
1 parent 928cdaa commit 39b6340

File tree

3 files changed

+28
-3
lines changed

3 files changed

+28
-3
lines changed

llvm/lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1395,7 +1395,7 @@ class AMDGPUAsmParser : public MCTargetAsmParser {
13951395
MCRegister ParseRegList(RegisterKind &RegKind, unsigned &RegNum,
13961396
unsigned &RegWidth,
13971397
SmallVectorImpl<AsmToken> &Tokens);
1398-
bool ParseRegRange(unsigned& Num, unsigned& Width);
1398+
bool ParseRegRange(unsigned &Num, unsigned &Width, unsigned &SubReg);
13991399
MCRegister getRegularReg(RegisterKind RegKind, unsigned RegNum,
14001400
unsigned SubReg, unsigned RegWidth, SMLoc Loc);
14011401

@@ -2857,7 +2857,8 @@ MCRegister AMDGPUAsmParser::getRegularReg(RegisterKind RegKind, unsigned RegNum,
28572857
return Reg;
28582858
}
28592859

2860-
bool AMDGPUAsmParser::ParseRegRange(unsigned &Num, unsigned &RegWidth) {
2860+
bool AMDGPUAsmParser::ParseRegRange(unsigned &Num, unsigned &RegWidth,
2861+
unsigned &SubReg) {
28612862
int64_t RegLo, RegHi;
28622863
if (!skipToken(AsmToken::LBrac, "missing register index"))
28632864
return false;
@@ -2894,8 +2895,20 @@ bool AMDGPUAsmParser::ParseRegRange(unsigned &Num, unsigned &RegWidth) {
28942895
return false;
28952896
}
28962897

2898+
if (RegHi == RegLo) {
2899+
StringRef RegSuffix = getTokenStr();
2900+
if (RegSuffix == ".l") {
2901+
SubReg = AMDGPU::lo16;
2902+
lex();
2903+
} else if (RegSuffix == ".h") {
2904+
SubReg = AMDGPU::hi16;
2905+
lex();
2906+
}
2907+
}
2908+
28972909
Num = static_cast<unsigned>(RegLo);
28982910
RegWidth = 32 * ((RegHi - RegLo) + 1);
2911+
28992912
return true;
29002913
}
29012914

@@ -2949,7 +2962,7 @@ MCRegister AMDGPUAsmParser::ParseRegularReg(RegisterKind &RegKind,
29492962
RegWidth = 32;
29502963
} else {
29512964
// Range of registers: v[XX:YY]. ":YY" is optional.
2952-
if (!ParseRegRange(RegNum, RegWidth))
2965+
if (!ParseRegRange(RegNum, RegWidth, SubReg))
29532966
return MCRegister();
29542967
}
29552968

llvm/test/MC/AMDGPU/gfx11_asm_vop1.s

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3808,3 +3808,9 @@ v_trunc_f64 v[5:6], src_scc
38083808

38093809
v_trunc_f64 v[254:255], 0xaf123456
38103810
// GFX11: v_trunc_f64_e32 v[254:255], 0xaf123456 ; encoding: [0xff,0x2e,0xfc,0x7f,0x56,0x34,0x12,0xaf]
3811+
3812+
v_trunc_f16 v[5].l, v[1].h
3813+
// GFX11: v_trunc_f16_e32 v5.l, v1.h ; encoding: [0x81,0xbb,0x0a,0x7e]
3814+
3815+
v_trunc_f16 v[5:5].l, v[1:1].h
3816+
// GFX11: v_trunc_f16_e32 v5.l, v1.h ; encoding: [0x81,0xbb,0x0a,0x7e]

llvm/test/MC/AMDGPU/gfx11_asm_vop1_t16_err.s

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1231,3 +1231,9 @@ v_trunc_f16_e32 v5.l, v199.l dpp8:[7,6,5,4,3,2,1,0]
12311231

12321232
v_trunc_f16_e32 v5.l, v199.l quad_perm:[3,2,1,0]
12331233
// GFX11: :[[@LINE-1]]:23: error: invalid operand for instruction
1234+
1235+
v_ceil_f16_e32 v[5:5].s, 0xfe0b
1236+
// GFX11: :[[@LINE-1]]:22: error: invalid operand for instruction
1237+
1238+
v_ceil_f16_e32 v[6:7].l, 0xfe0b
1239+
// GFX11: :[[@LINE-1]]:16: error: invalid operand for instruction

0 commit comments

Comments
 (0)