Rename msasm to alignstack per review.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@84795 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Dale Johannesen 2009-10-21 23:28:00 +00:00
parent e31cd34b8a
commit 8ba2d5befc
10 changed files with 33 additions and 27 deletions

View File

@ -2339,9 +2339,9 @@ has undefined behavior.</p>
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>
@ -2369,12 +2369,16 @@ call void asm sideeffect "eieio", ""()
</pre>
</div>
<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>
call void asm msasm "eieio", ""()
call void asm alignstack "eieio", ""()
</pre>
</div>

View File

@ -31,11 +31,11 @@ class InlineAsm : public Value {
std::string AsmString, Constraints;
bool HasSideEffects;
bool IsMsAsm;
bool IsAlignStack;
InlineAsm(const FunctionType *Ty, const StringRef &AsmString,
const StringRef &Constraints, bool hasSideEffects,
bool isMsAsm = false);
bool isAlignStack = false);
virtual ~InlineAsm();
public:
@ -43,10 +43,10 @@ public:
///
static InlineAsm *get(const FunctionType *Ty, const StringRef &AsmString,
const StringRef &Constraints, bool hasSideEffects,
bool isMsAsm = false);
bool isAlignStack = false);
bool hasSideEffects() const { return HasSideEffects; }
bool isMsAsm() const { return IsMsAsm; }
bool isAlignStack() const { return IsAlignStack; }
/// getType - InlineAsm's are always pointers.
///

View File

@ -529,7 +529,7 @@ lltok::Kind LLLexer::LexIdentifier() {
KEYWORD(module);
KEYWORD(asm);
KEYWORD(sideeffect);
KEYWORD(msasm);
KEYWORD(alignstack);
KEYWORD(gc);
KEYWORD(ccc);

View File

@ -1974,17 +1974,17 @@ bool LLParser::ParseValID(ValID &ID) {
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) ||
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();
ID.UIntVal = HasSideEffect | ((unsigned)MsAsm<<1);
ID.UIntVal = HasSideEffect | ((unsigned)AlignStack<<1);
ID.Kind = ValID::t_InlineAsm;
return false;
}

View File

@ -62,7 +62,7 @@ namespace lltok {
kw_module,
kw_asm,
kw_sideeffect,
kw_msasm,
kw_alignstack,
kw_gc,
kw_c,

View File

@ -1165,7 +1165,7 @@ bool BitcodeReader::ParseConstants() {
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");
@ -1179,7 +1179,7 @@ bool BitcodeReader::ParseConstants() {
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);
break;
}
}

View File

@ -678,7 +678,7 @@ static void WriteConstants(unsigned FirstVal, unsigned LastVal,
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();

View File

@ -1205,8 +1205,8 @@ static void WriteAsOperandInternal(raw_ostream &Out, const Value *V,
Out << "asm ";
if (IA->hasSideEffects())
Out << "sideeffect ";
if (IA->isMsAsm())
Out << "msasm ";
if (IA->isAlignStack())
Out << "alignstack ";
Out << '"';
PrintEscapedString(IA->getAsmString(), Out);
Out << "\", \"";

View File

@ -885,9 +885,9 @@ LLVMValueRef LLVMConstInsertValue(LLVMValueRef AggConstant,
LLVMValueRef LLVMConstInlineAsm(LLVMTypeRef Ty, const char *AsmString,
const char *Constraints, int HasSideEffects,
int IsMsAsm) {
int IsAlignStack) {
return wrap(InlineAsm::get(dyn_cast<FunctionType>(unwrap(Ty)), AsmString,
Constraints, HasSideEffects, IsMsAsm));
Constraints, HasSideEffects, IsAlignStack));
}
/*--.. Operations on global variables, functions, and aliases (globals) ....--*/

View File

@ -28,18 +28,20 @@ InlineAsm::~InlineAsm() {
InlineAsm *InlineAsm::get(const FunctionType *Ty, const StringRef &AsmString,
const StringRef &Constraints, bool hasSideEffects,
bool isMsAsm) {
bool isAlignStack) {
// FIXME: memoize!
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,
bool isMsAsm)
bool isAlignStack)
: 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!");