[ms-inline asm] Add the inline assembly dialect, AsmDialect, to the InlineAsm

class.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@163175 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chad Rosier 2012-09-04 22:46:24 +00:00
parent 4e2132e7ae
commit 03fe8f6ab6
4 changed files with 30 additions and 17 deletions

View File

@ -43,10 +43,12 @@ class InlineAsm : public Value {
std::string AsmString, Constraints; std::string AsmString, Constraints;
bool HasSideEffects; bool HasSideEffects;
bool IsAlignStack; bool IsAlignStack;
/// AsmDialect - 0 is AT&T (default) and 1 is the Intel dialect.
unsigned AsmDialect;
InlineAsm(PointerType *Ty, const std::string &AsmString, InlineAsm(PointerType *Ty, const std::string &AsmString,
const std::string &Constraints, bool hasSideEffects, const std::string &Constraints, bool hasSideEffects,
bool isAlignStack); bool isAlignStack, unsigned asmDialect);
virtual ~InlineAsm(); virtual ~InlineAsm();
/// When the ConstantUniqueMap merges two types and makes two InlineAsms /// When the ConstantUniqueMap merges two types and makes two InlineAsms
@ -58,11 +60,12 @@ public:
/// ///
static InlineAsm *get(FunctionType *Ty, StringRef AsmString, static InlineAsm *get(FunctionType *Ty, StringRef AsmString,
StringRef Constraints, bool hasSideEffects, StringRef Constraints, bool hasSideEffects,
bool isAlignStack = false); bool isAlignStack = false, unsigned asmDialect = 0);
bool hasSideEffects() const { return HasSideEffects; } bool hasSideEffects() const { return HasSideEffects; }
bool isAlignStack() const { return IsAlignStack; } bool isAlignStack() const { return IsAlignStack; }
unsigned getDialect() const { return AsmDialect; }
/// getType - InlineAsm's are always pointers. /// getType - InlineAsm's are always pointers.
/// ///
PointerType *getType() const { PointerType *getType() const {

View File

@ -352,18 +352,21 @@ struct ExprMapKeyType {
struct InlineAsmKeyType { struct InlineAsmKeyType {
InlineAsmKeyType(StringRef AsmString, InlineAsmKeyType(StringRef AsmString,
StringRef Constraints, bool hasSideEffects, StringRef Constraints, bool hasSideEffects,
bool isAlignStack) bool isAlignStack, unsigned asmDialect)
: asm_string(AsmString), constraints(Constraints), : asm_string(AsmString), constraints(Constraints),
has_side_effects(hasSideEffects), is_align_stack(isAlignStack) {} has_side_effects(hasSideEffects), is_align_stack(isAlignStack),
asm_dialect(asmDialect) {}
std::string asm_string; std::string asm_string;
std::string constraints; std::string constraints;
bool has_side_effects; bool has_side_effects;
bool is_align_stack; bool is_align_stack;
unsigned asm_dialect;
bool operator==(const InlineAsmKeyType& that) const { bool operator==(const InlineAsmKeyType& that) const {
return this->asm_string == that.asm_string && return this->asm_string == that.asm_string &&
this->constraints == that.constraints && this->constraints == that.constraints &&
this->has_side_effects == that.has_side_effects && this->has_side_effects == that.has_side_effects &&
this->is_align_stack == that.is_align_stack; this->is_align_stack == that.is_align_stack &&
this->asm_dialect == that.asm_dialect;
} }
bool operator<(const InlineAsmKeyType& that) const { bool operator<(const InlineAsmKeyType& that) const {
if (this->asm_string != that.asm_string) if (this->asm_string != that.asm_string)
@ -374,6 +377,8 @@ struct InlineAsmKeyType {
return this->has_side_effects < that.has_side_effects; return this->has_side_effects < that.has_side_effects;
if (this->is_align_stack != that.is_align_stack) if (this->is_align_stack != that.is_align_stack)
return this->is_align_stack < that.is_align_stack; return this->is_align_stack < that.is_align_stack;
if (this->asm_dialect != that.asm_dialect)
return this->asm_dialect < that.asm_dialect;
return false; return false;
} }
@ -490,7 +495,8 @@ template<>
struct ConstantCreator<InlineAsm, PointerType, InlineAsmKeyType> { struct ConstantCreator<InlineAsm, PointerType, InlineAsmKeyType> {
static InlineAsm *create(PointerType *Ty, const InlineAsmKeyType &Key) { static InlineAsm *create(PointerType *Ty, const InlineAsmKeyType &Key) {
return new InlineAsm(Ty, Key.asm_string, Key.constraints, return new InlineAsm(Ty, Key.asm_string, Key.constraints,
Key.has_side_effects, Key.is_align_stack); Key.has_side_effects, Key.is_align_stack,
Key.asm_dialect);
} }
}; };
@ -499,7 +505,8 @@ struct ConstantKeyData<InlineAsm> {
typedef InlineAsmKeyType ValType; typedef InlineAsmKeyType ValType;
static ValType getValType(InlineAsm *Asm) { static ValType getValType(InlineAsm *Asm) {
return InlineAsmKeyType(Asm->getAsmString(), Asm->getConstraintString(), return InlineAsmKeyType(Asm->getAsmString(), Asm->getConstraintString(),
Asm->hasSideEffects(), Asm->isAlignStack()); Asm->hasSideEffects(), Asm->isAlignStack(),
Asm->getDialect());
} }
}; };

View File

@ -1055,9 +1055,11 @@ LLVMValueRef LLVMConstInsertValue(LLVMValueRef AggConstant,
LLVMValueRef LLVMConstInlineAsm(LLVMTypeRef Ty, const char *AsmString, LLVMValueRef LLVMConstInlineAsm(LLVMTypeRef Ty, const char *AsmString,
const char *Constraints, const char *Constraints,
LLVMBool HasSideEffects, LLVMBool HasSideEffects,
LLVMBool IsAlignStack) { LLVMBool IsAlignStack,
unsigned AsmDialect) {
return wrap(InlineAsm::get(dyn_cast<FunctionType>(unwrap(Ty)), AsmString, return wrap(InlineAsm::get(dyn_cast<FunctionType>(unwrap(Ty)), AsmString,
Constraints, HasSideEffects, IsAlignStack)); Constraints, HasSideEffects, IsAlignStack,
AsmDialect));
} }
LLVMValueRef LLVMBlockAddress(LLVMValueRef F, LLVMBasicBlockRef BB) { LLVMValueRef LLVMBlockAddress(LLVMValueRef F, LLVMBasicBlockRef BB) {

View File

@ -27,19 +27,20 @@ InlineAsm::~InlineAsm() {
InlineAsm *InlineAsm::get(FunctionType *Ty, StringRef AsmString, InlineAsm *InlineAsm::get(FunctionType *Ty, StringRef AsmString,
StringRef Constraints, bool hasSideEffects, StringRef Constraints, bool hasSideEffects,
bool isAlignStack) { bool isAlignStack, unsigned asmDialect) {
InlineAsmKeyType Key(AsmString, Constraints, hasSideEffects, isAlignStack); InlineAsmKeyType Key(AsmString, Constraints, hasSideEffects, isAlignStack,
asmDialect);
LLVMContextImpl *pImpl = Ty->getContext().pImpl; LLVMContextImpl *pImpl = Ty->getContext().pImpl;
return pImpl->InlineAsms.getOrCreate(PointerType::getUnqual(Ty), Key); return pImpl->InlineAsms.getOrCreate(PointerType::getUnqual(Ty), Key);
} }
InlineAsm::InlineAsm(PointerType *Ty, const std::string &asmString, InlineAsm::InlineAsm(PointerType *Ty, const std::string &asmString,
const std::string &constraints, bool hasSideEffects, const std::string &constraints, bool hasSideEffects,
bool isAlignStack) bool isAlignStack, unsigned asmDialect)
: Value(Ty, Value::InlineAsmVal), : Value(Ty, Value::InlineAsmVal),
AsmString(asmString), AsmString(asmString), Constraints(constraints),
Constraints(constraints), HasSideEffects(hasSideEffects), HasSideEffects(hasSideEffects), IsAlignStack(isAlignStack),
IsAlignStack(isAlignStack) { AsmDialect(asmDialect) {
// Do various checks on the constraint string and type. // Do various checks on the constraint string and type.
assert(Verify(getFunctionType(), constraints) && assert(Verify(getFunctionType(), constraints) &&