summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorJakob Stoklund Olesen <stoklund@2pi.dk>2011-10-12 23:37:29 +0000
committerJakob Stoklund Olesen <stoklund@2pi.dk>2011-10-12 23:37:29 +0000
commit459b74b9644c4741d93fe73adc2b06ca6bdb366d (patch)
treeb1cdd1d49326e6e2e6a5928d9c34ea0ceadfd4e7 /include
parenta3a1635d04667a7674d754ce13bc44d43d4b26e9 (diff)
downloadllvm-459b74b9644c4741d93fe73adc2b06ca6bdb366d.tar.gz
llvm-459b74b9644c4741d93fe73adc2b06ca6bdb366d.tar.bz2
llvm-459b74b9644c4741d93fe73adc2b06ca6bdb366d.tar.xz
Encode register class constreaints in inline asm instructions.
The inline asm operand constraint is initially encoded in the virtual register for the operand, but that register class may change during coalescing, and the original constraint is lost. Encode the original register class as part of the flag word for each inline asm operand. This makes it possible to recover the actual constraint required by inline asm, just like we can for normal instructions. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@141833 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include')
-rw-r--r--include/llvm/InlineAsm.h29
1 files changed, 29 insertions, 0 deletions
diff --git a/include/llvm/InlineAsm.h b/include/llvm/InlineAsm.h
index fe8a714dd9..de5ce4ecaf 100644
--- a/include/llvm/InlineAsm.h
+++ b/include/llvm/InlineAsm.h
@@ -219,6 +219,7 @@ public:
static unsigned getFlagWord(unsigned Kind, unsigned NumOps) {
assert(((NumOps << 3) & ~0xffff) == 0 && "Too many inline asm operands!");
+ assert(Kind >= Kind_RegUse && Kind <= Kind_Mem && "Invalid Kind");
return Kind | (NumOps << 3);
}
@@ -227,9 +228,24 @@ public:
/// to a previous output operand.
static unsigned getFlagWordForMatchingOp(unsigned InputFlag,
unsigned MatchedOperandNo) {
+ assert(MatchedOperandNo <= 0x7fff && "Too big matched operand");
+ assert((InputFlag & ~0xffff) == 0 && "High bits already contain data");
return InputFlag | Flag_MatchingOperand | (MatchedOperandNo << 16);
}
+ /// getFlagWordForRegClass - Augment an existing flag word returned by
+ /// getFlagWord with the required register class for the following register
+ /// operands.
+ /// A tied use operand cannot have a register class, use the register class
+ /// from the def operand instead.
+ static unsigned getFlagWordForRegClass(unsigned InputFlag, unsigned RC) {
+ // Store RC + 1, reserve the value 0 to mean 'no register class'.
+ ++RC;
+ assert(RC <= 0x7fff && "Too large register class ID");
+ assert((InputFlag & ~0xffff) == 0 && "High bits already contain data");
+ return InputFlag | (RC << 16);
+ }
+
static unsigned getKind(unsigned Flags) {
return Flags & 7;
}
@@ -259,6 +275,19 @@ public:
return true;
}
+ /// hasRegClassConstraint - Returns true if the flag contains a register
+ /// class constraint. Sets RC to the register class ID.
+ static bool hasRegClassConstraint(unsigned Flag, unsigned &RC) {
+ if (Flag & Flag_MatchingOperand)
+ return false;
+ unsigned High = Flag >> 16;
+ // getFlagWordForRegClass() uses 0 to mean no register class, and otherwise
+ // stores RC + 1.
+ if (!High)
+ return false;
+ RC = High - 1;
+ return true;
+ }
};