]> granicus.if.org Git - clang/commitdiff
Clang side support for @cc assembly operands.
authorNirav Dave <niravd@google.com>
Fri, 18 Jan 2019 15:57:23 +0000 (15:57 +0000)
committerNirav Dave <niravd@google.com>
Fri, 18 Jan 2019 15:57:23 +0000 (15:57 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@351559 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Basic/Targets/X86.cpp

index 53b4c153e952c7f036331c405427ff9f84863f20..c0b2365e8df175f91cf899c82a3e810268b7fdb6 100644 (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':