Skip to content

Commit 4180996

Browse files
committed
fixup! Address CR comments and remove optional register code (will push this later)
1 parent 9a0636a commit 4180996

File tree

4 files changed

+22
-24
lines changed

4 files changed

+22
-24
lines changed

llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3908,8 +3908,6 @@ bool AArch64AsmParser::parseSysAlias(StringRef Name, SMLoc NameLoc,
39083908
StringRef Op = Tok.getString();
39093909
SMLoc S = Tok.getLoc();
39103910
bool ExpectRegister = true;
3911-
bool OptionalRegister = false;
3912-
bool hasAll = getSTI().hasFeature(AArch64::FeatureAll);
39133911

39143912
if (Mnemonic == "ic") {
39153913
const AArch64IC::IC *IC = AArch64IC::lookupICByName(Op);
@@ -3958,6 +3956,7 @@ bool AArch64AsmParser::parseSysAlias(StringRef Name, SMLoc NameLoc,
39583956
if (Op.lower() != "rctx")
39593957
return TokError("invalid operand for prediction restriction instruction");
39603958

3959+
bool hasAll = getSTI().hasFeature(AArch64::FeatureAll);
39613960
bool hasPredres = hasAll || getSTI().hasFeature(AArch64::FeaturePredRes);
39623961
bool hasSpecres2 = hasAll || getSTI().hasFeature(AArch64::FeatureSPECRES2);
39633962

@@ -3990,12 +3989,10 @@ bool AArch64AsmParser::parseSysAlias(StringRef Name, SMLoc NameLoc,
39903989
HasRegister = true;
39913990
}
39923991

3993-
if (!OptionalRegister) {
3994-
if (ExpectRegister && !HasRegister)
3995-
return TokError("specified " + Mnemonic + " op requires a register");
3996-
else if (!ExpectRegister && HasRegister)
3997-
return TokError("specified " + Mnemonic + " op does not use a register");
3998-
}
3992+
if (ExpectRegister && !HasRegister)
3993+
return TokError("specified " + Mnemonic + " op requires a register");
3994+
else if (!ExpectRegister && HasRegister)
3995+
return TokError("specified " + Mnemonic + " op does not use a register");
39993996

40003997
if (parseToken(AsmToken::EndOfStatement, "unexpected token in argument list"))
40013998
return true;

llvm/lib/Target/AArch64/MCTargetDesc/AArch64InstPrinter.cpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -917,7 +917,6 @@ bool AArch64InstPrinter::printSysAlias(const MCInst *MI,
917917
Encoding |= Op1Val << 11;
918918

919919
bool NeedsReg;
920-
bool OptionalReg = false;
921920
std::string Ins;
922921
std::string Name;
923922

@@ -1021,20 +1020,18 @@ bool AArch64InstPrinter::printSysAlias(const MCInst *MI,
10211020
StringRef Reg = getRegisterName(MI->getOperand(4).getReg());
10221021
bool NotXZR = Reg != "xzr";
10231022

1024-
// If a mandatory or optional register is not specified in the TableGen
1023+
// If a mandatory is not specified in the TableGen
10251024
// (i.e. no register operand should be present), and the register value
10261025
// is not xzr/x31, then disassemble to a SYS alias instead.
1027-
if (NotXZR && !NeedsReg && !OptionalReg)
1026+
if (NotXZR && !NeedsReg)
10281027
return false;
10291028

10301029
std::string Str = Ins + Name;
10311030
llvm::transform(Str, Str.begin(), ::tolower);
10321031

10331032
O << '\t' << Str;
10341033

1035-
// For optional registers, don't print the value if it's xzr/x31
1036-
// since this defaults to xzr/x31 if register is not specified.
1037-
if (NeedsReg || (OptionalReg && NotXZR)) {
1034+
if (NeedsReg) {
10381035
O << ", " << Reg;
10391036
}
10401037

llvm/lib/Target/AArch64/Utils/AArch64BaseInfo.h

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -409,16 +409,6 @@ struct SysAliasReg : SysAlias {
409409
: SysAlias(N, E, F), NeedsReg(R) {}
410410
};
411411

412-
struct SysAliasOptionalReg : SysAlias {
413-
bool NeedsReg;
414-
bool OptionalReg;
415-
constexpr SysAliasOptionalReg(const char *N, uint16_t E, bool R, bool O)
416-
: SysAlias(N, E), NeedsReg(R), OptionalReg(O) {}
417-
constexpr SysAliasOptionalReg(const char *N, uint16_t E, bool R, bool O,
418-
FeatureBitset F)
419-
: SysAlias(N, E, F), NeedsReg(R), OptionalReg(O) {}
420-
};
421-
422412
struct SysAliasImm : SysAlias {
423413
uint16_t ImmValue;
424414
constexpr SysAliasImm(const char *N, uint16_t E, uint16_t I)

llvm/test/MC/AArch64/arm64-aliases.s

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -512,6 +512,20 @@ foo:
512512
sys #4, c8, c3, #6
513513
; CHECK: tlbi vmalls12e1is
514514

515+
; Check that all 5 register bits are set (0x31):
516+
; (from Arm ARM regarding TLBI instructions without operands)
517+
; "Rt should be encoded as 0b11111. If the Rt field is not set to 0b11111,
518+
; it is CONSTRAINED UNPREDICTABLE whether:
519+
; * The instruction is UNDEFINED.
520+
; * The instruction behaves as if the Rt field is set to 0b11111."
521+
;
522+
; Do not disassemble this to `tlbi` but a SYS alias instead
523+
;
524+
sys #4, c8, c7, #6, x30
525+
; CHECK: sys #0x4, c8, c7, #0x6, x30
526+
sys #4, c8, c7, #6, x31
527+
; CHECK: tlbi vmalls12e1
528+
515529
ic ialluis
516530
; CHECK: ic ialluis ; encoding: [0x1f,0x71,0x08,0xd5]
517531
ic iallu

0 commit comments

Comments
 (0)