Skip to content

Commit d410e39

Browse files
committed
Clang side support for @cc assembly operands.
llvm-svn: 351559
1 parent 0a45bf0 commit d410e39

File tree

1 file changed

+52
-0
lines changed

1 file changed

+52
-0
lines changed

clang/lib/Basic/Targets/X86.cpp

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1554,6 +1554,42 @@ bool X86TargetInfo::validateCpuIs(StringRef FeatureStr) const {
15541554
.Default(false);
15551555
}
15561556

1557+
1558+
static unsigned matchAsmCCConstraint(const char *&Name) {
1559+
auto RV = llvm::StringSwitch<unsigned>(Name)
1560+
.Case("@cca", 4)
1561+
.Case("@ccae", 5)
1562+
.Case("@ccb", 4)
1563+
.Case("@ccbe", 5)
1564+
.Case("@ccc", 4)
1565+
.Case("@cce", 4)
1566+
.Case("@ccz", 4)
1567+
.Case("@ccg", 4)
1568+
.Case("@ccge", 4)
1569+
.Case("@ccl", 4)
1570+
.Case("@ccle", 5)
1571+
.Case("@ccna", 5)
1572+
.Case("@ccnae",6)
1573+
.Case("@ccnb", 5)
1574+
.Case("@ccnbe",6)
1575+
.Case("@ccnc", 5)
1576+
.Case("@ccne", 5)
1577+
.Case("@ccnz", 5)
1578+
.Case("@ccng", 5)
1579+
.Case("@ccnge",6)
1580+
.Case("@ccnl", 5)
1581+
.Case("@ccnle",6)
1582+
.Case("@ccno", 5)
1583+
.Case("@ccnp", 5)
1584+
.Case("@ccns", 5)
1585+
.Case("@cco", 4)
1586+
.Case("@ccp", 4)
1587+
.Case("@ccs", 4)
1588+
.Default(0);
1589+
return RV;
1590+
}
1591+
1592+
15571593
bool X86TargetInfo::validateAsmConstraint(
15581594
const char *&Name, TargetInfo::ConstraintInfo &Info) const {
15591595
switch (*Name) {
@@ -1636,6 +1672,14 @@ bool X86TargetInfo::validateAsmConstraint(
16361672
case 'C': // SSE floating point constant.
16371673
case 'G': // x87 floating point constant.
16381674
return true;
1675+
case '@':
1676+
// CC condition changes.
1677+
if (auto Len = matchAsmCCConstraint(Name)) {
1678+
Name+=Len-1;
1679+
Info.setAllowsRegister();
1680+
return true;
1681+
}
1682+
return false;
16391683
}
16401684
}
16411685

@@ -1705,8 +1749,16 @@ bool X86TargetInfo::validateOperandSize(StringRef Constraint,
17051749
return true;
17061750
}
17071751

1752+
//niravd
17081753
std::string X86TargetInfo::convertConstraint(const char *&Constraint) const {
17091754
switch (*Constraint) {
1755+
case '@':
1756+
if (auto Len = matchAsmCCConstraint(Constraint)) {
1757+
std::string Converted = "{" + std::string(Constraint, Len) + "}";
1758+
Constraint+=Len-1;
1759+
return Converted;
1760+
}
1761+
break;
17101762
case 'a':
17111763
return std::string("{ax}");
17121764
case 'b':

0 commit comments

Comments
 (0)