a special value. This value represents the inline assembler as a string
(containing the instructions to emit), a list of operand constraints (stored
as a string), a flag that indicates whether or not the inline asm
a special value. This value represents the inline assembler as a string
(containing the instructions to emit), a list of operand constraints (stored
as a string), a flag that indicates whether or not the inline asm
- expression has side effects, and a flag indicating whether the asm came
- originally from an asm block. An example inline assembler
- expression is:</p>
+ expression has side effects, and a flag indicating whether the function
+ containing the asm needs to align its stack conservatively. An example
+ inline assembler expression is:</p>
<div class="doc_code">
<pre>
<div class="doc_code">
<pre>
-<p>Inline asms derived from asm blocks are similarly marked with the
- '<tt>msasm</tt>' keyword:</p>
+<p>In some cases inline asms will contain code that will not work unless the
+ stack is aligned in some way, such as calls or SSE instructions on x86,
+ yet will not contain code that does that alignment within the asm.
+ The compiler should make conservative assumptions about what the asm might
+ contain and should generate its usual stack alignment code in the prologue
+ if the '<tt>alignstack</tt>' keyword is present:</p>
<div class="doc_code">
<pre>
<div class="doc_code">
<pre>
-call void asm msasm "eieio", ""()
+call void asm alignstack "eieio", ""()
std::string AsmString, Constraints;
bool HasSideEffects;
std::string AsmString, Constraints;
bool HasSideEffects;
InlineAsm(const FunctionType *Ty, const StringRef &AsmString,
const StringRef &Constraints, bool hasSideEffects,
InlineAsm(const FunctionType *Ty, const StringRef &AsmString,
const StringRef &Constraints, bool hasSideEffects,
+ bool isAlignStack = false);
virtual ~InlineAsm();
public:
virtual ~InlineAsm();
public:
///
static InlineAsm *get(const FunctionType *Ty, const StringRef &AsmString,
const StringRef &Constraints, bool hasSideEffects,
///
static InlineAsm *get(const FunctionType *Ty, const StringRef &AsmString,
const StringRef &Constraints, bool hasSideEffects,
+ bool isAlignStack = false);
bool hasSideEffects() const { return HasSideEffects; }
bool hasSideEffects() const { return HasSideEffects; }
- bool isMsAsm() const { return IsMsAsm; }
+ bool isAlignStack() const { return IsAlignStack; }
/// getType - InlineAsm's are always pointers.
///
/// getType - InlineAsm's are always pointers.
///
KEYWORD(module);
KEYWORD(asm);
KEYWORD(sideeffect);
KEYWORD(module);
KEYWORD(asm);
KEYWORD(sideeffect);
KEYWORD(gc);
KEYWORD(ccc);
KEYWORD(gc);
KEYWORD(ccc);
return false;
case lltok::kw_asm: {
return false;
case lltok::kw_asm: {
- // ValID ::= 'asm' SideEffect? MsAsm? STRINGCONSTANT ',' STRINGCONSTANT
- bool HasSideEffect, MsAsm;
+ // ValID ::= 'asm' SideEffect? AlignStack? STRINGCONSTANT ',' STRINGCONSTANT
+ bool HasSideEffect, AlignStack;
Lex.Lex();
if (ParseOptionalToken(lltok::kw_sideeffect, HasSideEffect) ||
Lex.Lex();
if (ParseOptionalToken(lltok::kw_sideeffect, HasSideEffect) ||
- ParseOptionalToken(lltok::kw_msasm, MsAsm) ||
+ ParseOptionalToken(lltok::kw_alignstack, AlignStack) ||
ParseStringConstant(ID.StrVal) ||
ParseToken(lltok::comma, "expected comma in inline asm expression") ||
ParseToken(lltok::StringConstant, "expected constraint string"))
return true;
ID.StrVal2 = Lex.getStrVal();
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 = HasSideEffect | ((unsigned)MsAsm<<1);
+ ID.UIntVal = HasSideEffect | ((unsigned)AlignStack<<1);
ID.Kind = ValID::t_InlineAsm;
return false;
}
ID.Kind = ValID::t_InlineAsm;
return false;
}
kw_module,
kw_asm,
kw_sideeffect,
kw_module,
kw_asm,
kw_sideeffect,
if (Record.size() < 2) return Error("Invalid INLINEASM record");
std::string AsmStr, ConstrStr;
bool HasSideEffects = Record[0] & 1;
if (Record.size() < 2) return Error("Invalid INLINEASM record");
std::string AsmStr, ConstrStr;
bool HasSideEffects = Record[0] & 1;
- bool IsMsAsm = Record[0] >> 1;
+ bool IsAlignStack = Record[0] >> 1;
unsigned AsmStrSize = Record[1];
if (2+AsmStrSize >= Record.size())
return Error("Invalid INLINEASM record");
unsigned AsmStrSize = Record[1];
if (2+AsmStrSize >= Record.size())
return Error("Invalid INLINEASM record");
ConstrStr += (char)Record[3+AsmStrSize+i];
const PointerType *PTy = cast<PointerType>(CurTy);
V = InlineAsm::get(cast<FunctionType>(PTy->getElementType()),
ConstrStr += (char)Record[3+AsmStrSize+i];
const PointerType *PTy = cast<PointerType>(CurTy);
V = InlineAsm::get(cast<FunctionType>(PTy->getElementType()),
- AsmStr, ConstrStr, HasSideEffects, IsMsAsm);
+ AsmStr, ConstrStr, HasSideEffects, IsAlignStack);
if (const InlineAsm *IA = dyn_cast<InlineAsm>(V)) {
Record.push_back(unsigned(IA->hasSideEffects()) |
if (const InlineAsm *IA = dyn_cast<InlineAsm>(V)) {
Record.push_back(unsigned(IA->hasSideEffects()) |
- unsigned(IA->isMsAsm()) << 1);
+ unsigned(IA->isAlignStack()) << 1);
// Add the asm string.
const std::string &AsmStr = IA->getAsmString();
// Add the asm string.
const std::string &AsmStr = IA->getAsmString();
Out << "asm ";
if (IA->hasSideEffects())
Out << "sideeffect ";
Out << "asm ";
if (IA->hasSideEffects())
Out << "sideeffect ";
- if (IA->isMsAsm())
- Out << "msasm ";
+ if (IA->isAlignStack())
+ Out << "alignstack ";
Out << '"';
PrintEscapedString(IA->getAsmString(), Out);
Out << "\", \"";
Out << '"';
PrintEscapedString(IA->getAsmString(), Out);
Out << "\", \"";
LLVMValueRef LLVMConstInlineAsm(LLVMTypeRef Ty, const char *AsmString,
const char *Constraints, int HasSideEffects,
LLVMValueRef LLVMConstInlineAsm(LLVMTypeRef Ty, const char *AsmString,
const char *Constraints, int HasSideEffects,
return wrap(InlineAsm::get(dyn_cast<FunctionType>(unwrap(Ty)), AsmString,
return wrap(InlineAsm::get(dyn_cast<FunctionType>(unwrap(Ty)), AsmString,
- Constraints, HasSideEffects, IsMsAsm));
+ Constraints, HasSideEffects, IsAlignStack));
}
/*--.. Operations on global variables, functions, and aliases (globals) ....--*/
}
/*--.. Operations on global variables, functions, and aliases (globals) ....--*/
InlineAsm *InlineAsm::get(const FunctionType *Ty, const StringRef &AsmString,
const StringRef &Constraints, bool hasSideEffects,
InlineAsm *InlineAsm::get(const FunctionType *Ty, const StringRef &AsmString,
const StringRef &Constraints, bool hasSideEffects,
- return new InlineAsm(Ty, AsmString, Constraints, hasSideEffects, isMsAsm);
+ return new InlineAsm(Ty, AsmString, Constraints, hasSideEffects,
+ isAlignStack);
}
InlineAsm::InlineAsm(const FunctionType *Ty, const StringRef &asmString,
const StringRef &constraints, bool hasSideEffects,
}
InlineAsm::InlineAsm(const FunctionType *Ty, const StringRef &asmString,
const StringRef &constraints, bool hasSideEffects,
: Value(PointerType::getUnqual(Ty),
Value::InlineAsmVal),
AsmString(asmString),
: Value(PointerType::getUnqual(Ty),
Value::InlineAsmVal),
AsmString(asmString),
- Constraints(constraints), HasSideEffects(hasSideEffects), IsMsAsm(isMsAsm) {
+ Constraints(constraints), HasSideEffects(hasSideEffects),
+ IsAlignStack(isAlignStack) {
// Do various checks on the constraint string and type.
assert(Verify(Ty, constraints) && "Function type not legal for constraints!");
// Do various checks on the constraint string and type.
assert(Verify(Ty, constraints) && "Function type not legal for constraints!");