summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChad Rosier <mcrosier@apple.com>2012-09-05 19:00:49 +0000
committerChad Rosier <mcrosier@apple.com>2012-09-05 19:00:49 +0000
commit581600bfc3060ee13afb278cd87e25da5b5f7db2 (patch)
tree1136bdd2faa7d5f5514193d9ca9c4f1138b62cef
parent7bebddf55ece46995f310d79195afb4e5b239886 (diff)
[ms-inline asm] Enumerate the InlineAsm dialects and rename the nsdialect to
inteldialect. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@163231 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--docs/LangRef.html13
-rw-r--r--include/llvm/Bitcode/LLVMBitCodes.h2
-rw-r--r--include/llvm/InlineAsm.h17
-rw-r--r--lib/AsmParser/LLLexer.cpp2
-rw-r--r--lib/AsmParser/LLParser.cpp8
-rw-r--r--lib/AsmParser/LLToken.h2
-rw-r--r--lib/Bitcode/Reader/BitcodeReader.cpp7
-rw-r--r--lib/VMCore/AsmWriter.cpp5
-rw-r--r--lib/VMCore/ConstantsContext.h4
-rw-r--r--lib/VMCore/Core.cpp2
-rw-r--r--lib/VMCore/InlineAsm.cpp6
11 files changed, 38 insertions, 30 deletions
diff --git a/docs/LangRef.html b/docs/LangRef.html
index 0699857bb1..4daab592e9 100644
--- a/docs/LangRef.html
+++ b/docs/LangRef.html
@@ -2894,19 +2894,18 @@ call void asm sideeffect "eieio", ""()
call void asm alignstack "eieio", ""()
</pre>
-<p>Inline asms also support using non-standard assembly dialects. The standard
- dialect is ATT, which is assumed when the '<tt>nsdialect</tt>' keyword is not
- present. When the '<tt>nsdialect</tt>' keyword is present, the dialect is
- assumed to be Intel. Currently, ATT and Intel are the only supported
- dialects. An example is:</p>
+<p>Inline asms also support using non-standard assembly dialects. The assumed
+ dialect is ATT. When the '<tt>inteldialect</tt>' keyword is present, the
+ inline asm is using the Intel dialect. Currently, ATT and Intel are the
+ only supported dialects. An example is:</p>
<pre class="doc_code">
-call void asm nsdialect "eieio", ""()
+call void asm inteldialect "eieio", ""()
</pre>
<p>If multiple keywords appear the '<tt>sideeffect</tt>' keyword must come
first, the '<tt>alignstack</tt>' keyword second and the
- '<tt>nsdialect</tt>' keyword last.</p>
+ '<tt>inteldialect</tt>' keyword last.</p>
<!--
<p>TODO: The format of the asm and constraints string still need to be
diff --git a/include/llvm/Bitcode/LLVMBitCodes.h b/include/llvm/Bitcode/LLVMBitCodes.h
index 3ac608b994..c1dc190304 100644
--- a/include/llvm/Bitcode/LLVMBitCodes.h
+++ b/include/llvm/Bitcode/LLVMBitCodes.h
@@ -168,7 +168,7 @@ namespace bitc {
CST_CODE_BLOCKADDRESS = 21, // CST_CODE_BLOCKADDRESS [fnty, fnval, bb#]
CST_CODE_DATA = 22, // DATA: [n x elements]
CST_CODE_INLINEASM = 23 // INLINEASM: [sideeffect|alignstack|
- // nsdialect,asmstr,conststr]
+ // asmdialect,asmstr,conststr]
};
/// CastOpcodes - These are values used in the bitcode files to encode which
diff --git a/include/llvm/InlineAsm.h b/include/llvm/InlineAsm.h
index 178602aa2f..dd7d7af140 100644
--- a/include/llvm/InlineAsm.h
+++ b/include/llvm/InlineAsm.h
@@ -33,6 +33,13 @@ template<class ConstantClass, class TypeClass, class ValType>
struct ConstantCreator;
class InlineAsm : public Value {
+public:
+ enum AsmDialect {
+ AD_ATT,
+ AD_Intel
+ };
+
+private:
friend struct ConstantCreator<InlineAsm, PointerType, InlineAsmKeyType>;
friend class ConstantUniqueMap<InlineAsmKeyType, const InlineAsmKeyType&,
PointerType, InlineAsm, false>;
@@ -43,12 +50,11 @@ class InlineAsm : public Value {
std::string AsmString, Constraints;
bool HasSideEffects;
bool IsAlignStack;
- /// AsmDialect - 0 is AT&T (default) and 1 is the Intel dialect.
- unsigned AsmDialect;
+ AsmDialect Dialect;
InlineAsm(PointerType *Ty, const std::string &AsmString,
const std::string &Constraints, bool hasSideEffects,
- bool isAlignStack, unsigned asmDialect);
+ bool isAlignStack, AsmDialect asmDialect);
virtual ~InlineAsm();
/// When the ConstantUniqueMap merges two types and makes two InlineAsms
@@ -60,11 +66,12 @@ public:
///
static InlineAsm *get(FunctionType *Ty, StringRef AsmString,
StringRef Constraints, bool hasSideEffects,
- bool isAlignStack = false, unsigned asmDialect = 0);
+ bool isAlignStack = false,
+ AsmDialect asmDialect = AD_ATT);
bool hasSideEffects() const { return HasSideEffects; }
bool isAlignStack() const { return IsAlignStack; }
- unsigned getDialect() const { return AsmDialect; }
+ AsmDialect getDialect() const { return Dialect; }
/// getType - InlineAsm's are always pointers.
///
diff --git a/lib/AsmParser/LLLexer.cpp b/lib/AsmParser/LLLexer.cpp
index b90c57152c..6e61665443 100644
--- a/lib/AsmParser/LLLexer.cpp
+++ b/lib/AsmParser/LLLexer.cpp
@@ -510,7 +510,7 @@ lltok::Kind LLLexer::LexIdentifier() {
KEYWORD(asm);
KEYWORD(sideeffect);
KEYWORD(alignstack);
- KEYWORD(nsdialect);
+ KEYWORD(inteldialect);
KEYWORD(gc);
KEYWORD(ccc);
diff --git a/lib/AsmParser/LLParser.cpp b/lib/AsmParser/LLParser.cpp
index 30c5596077..b0b64d89d9 100644
--- a/lib/AsmParser/LLParser.cpp
+++ b/lib/AsmParser/LLParser.cpp
@@ -2069,18 +2069,18 @@ bool LLParser::ParseValID(ValID &ID, PerFunctionState *PFS) {
case lltok::kw_asm: {
// ValID ::= 'asm' SideEffect? AlignStack? STRINGCONSTANT ',' STRINGCONSTANT
- bool HasSideEffect, AlignStack, NSDialect;
+ bool HasSideEffect, AlignStack, AsmDialect;
Lex.Lex();
if (ParseOptionalToken(lltok::kw_sideeffect, HasSideEffect) ||
ParseOptionalToken(lltok::kw_alignstack, AlignStack) ||
- ParseOptionalToken(lltok::kw_nsdialect, NSDialect) ||
+ ParseOptionalToken(lltok::kw_inteldialect, AsmDialect) ||
ParseStringConstant(ID.StrVal) ||
ParseToken(lltok::comma, "expected comma in inline asm expression") ||
ParseToken(lltok::StringConstant, "expected constraint string"))
return true;
ID.StrVal2 = Lex.getStrVal();
ID.UIntVal = unsigned(HasSideEffect) | (unsigned(AlignStack)<<1) |
- (unsigned(NSDialect)<<2);
+ (unsigned(AsmDialect)<<2);
ID.Kind = ValID::t_InlineAsm;
return false;
}
@@ -2498,7 +2498,7 @@ bool LLParser::ConvertValIDToValue(Type *Ty, ValID &ID, Value *&V,
if (!FTy || !InlineAsm::Verify(FTy, ID.StrVal2))
return Error(ID.Loc, "invalid type for inline asm constraint string");
V = InlineAsm::get(FTy, ID.StrVal, ID.StrVal2, ID.UIntVal&1,
- (ID.UIntVal>>1)&1, (ID.UIntVal>>2)&1);
+ (ID.UIntVal>>1)&1, (InlineAsm::AsmDialect(ID.UIntVal>>2)));
return false;
}
case ValID::t_MDNode:
diff --git a/lib/AsmParser/LLToken.h b/lib/AsmParser/LLToken.h
index 2cea1bb1f1..37cbf3003e 100644
--- a/lib/AsmParser/LLToken.h
+++ b/lib/AsmParser/LLToken.h
@@ -72,7 +72,7 @@ namespace lltok {
kw_asm,
kw_sideeffect,
kw_alignstack,
- kw_nsdialect,
+ kw_inteldialect,
kw_gc,
kw_c,
diff --git a/lib/Bitcode/Reader/BitcodeReader.cpp b/lib/Bitcode/Reader/BitcodeReader.cpp
index 078188b742..a5b34f4898 100644
--- a/lib/Bitcode/Reader/BitcodeReader.cpp
+++ b/lib/Bitcode/Reader/BitcodeReader.cpp
@@ -1245,7 +1245,7 @@ bool BitcodeReader::ParseConstants() {
V = ConstantExpr::getICmp(Record[3], Op0, Op1);
break;
}
- // This maintains backward compatibility, pre-'nsdialect'.
+ // This maintains backward compatibility, pre-asm dialect keywords.
// FIXME: Remove with the 4.0 release.
case bitc::CST_CODE_INLINEASM_OLD: {
if (Record.size() < 2) return Error("Invalid INLINEASM record");
@@ -1268,7 +1268,8 @@ bool BitcodeReader::ParseConstants() {
AsmStr, ConstrStr, HasSideEffects, IsAlignStack);
break;
}
- // This version adds support for the 'nsdialect' keyword.
+ // This version adds support for the asm dialect keywords (e.g.,
+ // inteldialect).
case bitc::CST_CODE_INLINEASM: {
if (Record.size() < 2) return Error("Invalid INLINEASM record");
std::string AsmStr, ConstrStr;
@@ -1289,7 +1290,7 @@ bool BitcodeReader::ParseConstants() {
PointerType *PTy = cast<PointerType>(CurTy);
V = InlineAsm::get(cast<FunctionType>(PTy->getElementType()),
AsmStr, ConstrStr, HasSideEffects, IsAlignStack,
- AsmDialect);
+ InlineAsm::AsmDialect(AsmDialect));
break;
}
case bitc::CST_CODE_BLOCKADDRESS:{
diff --git a/lib/VMCore/AsmWriter.cpp b/lib/VMCore/AsmWriter.cpp
index f937ebdd32..f3f24ae5c8 100644
--- a/lib/VMCore/AsmWriter.cpp
+++ b/lib/VMCore/AsmWriter.cpp
@@ -1029,8 +1029,9 @@ static void WriteAsOperandInternal(raw_ostream &Out, const Value *V,
Out << "sideeffect ";
if (IA->isAlignStack())
Out << "alignstack ";
- if (IA->getDialect() != 0)
- Out << "nsdialect ";
+ // We don't emit the AD_ATT dialect as it's the assumed default.
+ if (IA->getDialect() == InlineAsm::AD_Intel)
+ Out << "inteldialect ";
Out << '"';
PrintEscapedString(IA->getAsmString(), Out);
Out << "\", \"";
diff --git a/lib/VMCore/ConstantsContext.h b/lib/VMCore/ConstantsContext.h
index ddd680a55d..0f81b3ee4e 100644
--- a/lib/VMCore/ConstantsContext.h
+++ b/lib/VMCore/ConstantsContext.h
@@ -352,7 +352,7 @@ struct ExprMapKeyType {
struct InlineAsmKeyType {
InlineAsmKeyType(StringRef AsmString,
StringRef Constraints, bool hasSideEffects,
- bool isAlignStack, unsigned asmDialect)
+ bool isAlignStack, InlineAsm::AsmDialect asmDialect)
: asm_string(AsmString), constraints(Constraints),
has_side_effects(hasSideEffects), is_align_stack(isAlignStack),
asm_dialect(asmDialect) {}
@@ -360,7 +360,7 @@ struct InlineAsmKeyType {
std::string constraints;
bool has_side_effects;
bool is_align_stack;
- unsigned asm_dialect;
+ InlineAsm::AsmDialect asm_dialect;
bool operator==(const InlineAsmKeyType& that) const {
return this->asm_string == that.asm_string &&
this->constraints == that.constraints &&
diff --git a/lib/VMCore/Core.cpp b/lib/VMCore/Core.cpp
index 9ce76f87fa..ab27f9b8b7 100644
--- a/lib/VMCore/Core.cpp
+++ b/lib/VMCore/Core.cpp
@@ -1056,7 +1056,7 @@ LLVMValueRef LLVMConstInlineAsm(LLVMTypeRef Ty, const char *AsmString,
const char *Constraints,
LLVMBool HasSideEffects,
LLVMBool IsAlignStack,
- unsigned AsmDialect) {
+ InlineAsm::AsmDialect AsmDialect) {
return wrap(InlineAsm::get(dyn_cast<FunctionType>(unwrap(Ty)), AsmString,
Constraints, HasSideEffects, IsAlignStack,
AsmDialect));
diff --git a/lib/VMCore/InlineAsm.cpp b/lib/VMCore/InlineAsm.cpp
index 92414e0cef..2e636aacfd 100644
--- a/lib/VMCore/InlineAsm.cpp
+++ b/lib/VMCore/InlineAsm.cpp
@@ -27,7 +27,7 @@ InlineAsm::~InlineAsm() {
InlineAsm *InlineAsm::get(FunctionType *Ty, StringRef AsmString,
StringRef Constraints, bool hasSideEffects,
- bool isAlignStack, unsigned asmDialect) {
+ bool isAlignStack, AsmDialect asmDialect) {
InlineAsmKeyType Key(AsmString, Constraints, hasSideEffects, isAlignStack,
asmDialect);
LLVMContextImpl *pImpl = Ty->getContext().pImpl;
@@ -36,11 +36,11 @@ InlineAsm *InlineAsm::get(FunctionType *Ty, StringRef AsmString,
InlineAsm::InlineAsm(PointerType *Ty, const std::string &asmString,
const std::string &constraints, bool hasSideEffects,
- bool isAlignStack, unsigned asmDialect)
+ bool isAlignStack, AsmDialect asmDialect)
: Value(Ty, Value::InlineAsmVal),
AsmString(asmString), Constraints(constraints),
HasSideEffects(hasSideEffects), IsAlignStack(isAlignStack),
- AsmDialect(asmDialect) {
+ Dialect(asmDialect) {
// Do various checks on the constraint string and type.
assert(Verify(getFunctionType(), constraints) &&