Clang side support for @cc assembly operands.

llvm-svn: 351559
This commit is contained in:
Nirav Dave 2019-01-18 15:57:23 +00:00
parent 0a45bf0e55
commit d410e392cd
1 changed files with 52 additions and 0 deletions

View File

@ -1554,6 +1554,42 @@ bool X86TargetInfo::validateCpuIs(StringRef FeatureStr) const {
.Default(false);
}
static unsigned matchAsmCCConstraint(const char *&Name) {
auto RV = llvm::StringSwitch<unsigned>(Name)
.Case("@cca", 4)
.Case("@ccae", 5)
.Case("@ccb", 4)
.Case("@ccbe", 5)
.Case("@ccc", 4)
.Case("@cce", 4)
.Case("@ccz", 4)
.Case("@ccg", 4)
.Case("@ccge", 4)
.Case("@ccl", 4)
.Case("@ccle", 5)
.Case("@ccna", 5)
.Case("@ccnae",6)
.Case("@ccnb", 5)
.Case("@ccnbe",6)
.Case("@ccnc", 5)
.Case("@ccne", 5)
.Case("@ccnz", 5)
.Case("@ccng", 5)
.Case("@ccnge",6)
.Case("@ccnl", 5)
.Case("@ccnle",6)
.Case("@ccno", 5)
.Case("@ccnp", 5)
.Case("@ccns", 5)
.Case("@cco", 4)
.Case("@ccp", 4)
.Case("@ccs", 4)
.Default(0);
return RV;
}
bool X86TargetInfo::validateAsmConstraint(
const char *&Name, TargetInfo::ConstraintInfo &Info) const {
switch (*Name) {
@ -1636,6 +1672,14 @@ bool X86TargetInfo::validateAsmConstraint(
case 'C': // SSE floating point constant.
case 'G': // x87 floating point constant.
return true;
case '@':
// CC condition changes.
if (auto Len = matchAsmCCConstraint(Name)) {
Name+=Len-1;
Info.setAllowsRegister();
return true;
}
return false;
}
}
@ -1705,8 +1749,16 @@ bool X86TargetInfo::validateOperandSize(StringRef Constraint,
return true;
}
//niravd
std::string X86TargetInfo::convertConstraint(const char *&Constraint) const {
switch (*Constraint) {
case '@':
if (auto Len = matchAsmCCConstraint(Constraint)) {
std::string Converted = "{" + std::string(Constraint, Len) + "}";
Constraint+=Len-1;
return Converted;
}
break;
case 'a':
return std::string("{ax}");
case 'b':