summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorEd Schouten <ed@FreeBSD.org>2009-06-23 14:50:01 +0000
committerEd Schouten <ed@FreeBSD.org>2009-06-23 14:50:01 +0000
commit0408e1d309a743aca4ed4592cf2c712a71537901 (patch)
tree6be075b410677415707e0987e3a49123130cef22 /tools
parentb2f21fb044b6b5c52cff6227f9f79ca4ed42b18f (diff)
downloadsrc-test2-0408e1d309a743aca4ed4592cf2c712a71537901.tar.gz
src-test2-0408e1d309a743aca4ed4592cf2c712a71537901.zip
Notes
Diffstat (limited to 'tools')
-rw-r--r--tools/llvm-mc/AsmLexer.cpp26
-rw-r--r--tools/llvm-mc/AsmLexer.h5
-rw-r--r--tools/llvm-mc/AsmParser.cpp60
-rw-r--r--tools/llvm-mc/AsmParser.h1
-rw-r--r--tools/lto/LTOCodeGenerator.cpp5
5 files changed, 90 insertions, 7 deletions
diff --git a/tools/llvm-mc/AsmLexer.cpp b/tools/llvm-mc/AsmLexer.cpp
index 0828594a35b5..dbd3c06db772 100644
--- a/tools/llvm-mc/AsmLexer.cpp
+++ b/tools/llvm-mc/AsmLexer.cpp
@@ -14,6 +14,7 @@
#include "AsmLexer.h"
#include "llvm/Support/SourceMgr.h"
#include "llvm/Support/MemoryBuffer.h"
+#include "llvm/Config/config.h" // for strtoull.
#include <cerrno>
#include <cstdio>
#include <cstdlib>
@@ -74,17 +75,18 @@ asmtok::TokKind AsmLexer::LexIdentifier() {
while (isalnum(*CurPtr) || *CurPtr == '_' || *CurPtr == '$' ||
*CurPtr == '.' || *CurPtr == '@')
++CurPtr;
- CurStrVal.assign(TokStart, CurPtr); // Include %
+ CurStrVal.assign(TokStart, CurPtr);
return asmtok::Identifier;
}
/// LexPercent: Register: %[a-zA-Z0-9]+
asmtok::TokKind AsmLexer::LexPercent() {
if (!isalnum(*CurPtr))
- return ReturnError(TokStart, "invalid register name");
+ return asmtok::Percent; // Single %.
+
while (isalnum(*CurPtr))
++CurPtr;
- CurStrVal.assign(TokStart, CurPtr); // Skip %
+ CurStrVal.assign(TokStart, CurPtr); // Include %
return asmtok::Register;
}
@@ -242,6 +244,10 @@ asmtok::TokKind AsmLexer::LexToken() {
case '*': return asmtok::Star;
case ',': return asmtok::Comma;
case '$': return asmtok::Dollar;
+ case '|': return asmtok::Pipe;
+ case '^': return asmtok::Caret;
+ case '&': return asmtok::Amp;
+ case '!': return asmtok::Exclaim;
case '%': return LexPercent();
case '/': return LexSlash();
case '#': return LexHash();
@@ -249,6 +255,20 @@ asmtok::TokKind AsmLexer::LexToken() {
case '0': case '1': case '2': case '3': case '4':
case '5': case '6': case '7': case '8': case '9':
return LexDigit();
+ case '<':
+ if (*CurPtr == '<') {
+ ++CurPtr;
+ return asmtok::LessLess;
+ }
+ // Don't have any use for bare '<' yet.
+ return ReturnError(TokStart, "invalid character in input");
+ case '>':
+ if (*CurPtr == '>') {
+ ++CurPtr;
+ return asmtok::GreaterGreater;
+ }
+ // Don't have any use for bare '>' yet.
+ return ReturnError(TokStart, "invalid character in input");
// TODO: Quoted identifiers (objc methods etc)
// local labels: [0-9][:]
diff --git a/tools/llvm-mc/AsmLexer.h b/tools/llvm-mc/AsmLexer.h
index a6c93230c6cd..23c5f851bc07 100644
--- a/tools/llvm-mc/AsmLexer.h
+++ b/tools/llvm-mc/AsmLexer.h
@@ -42,7 +42,10 @@ namespace asmtok {
Plus, Minus, Tilde,
Slash, // '/'
LParen, RParen,
- Star, Comma, Dollar
+ Star, Comma, Dollar,
+
+ Pipe, Caret, Amp, Exclaim,
+ Percent, LessLess, GreaterGreater
};
}
diff --git a/tools/llvm-mc/AsmParser.cpp b/tools/llvm-mc/AsmParser.cpp
index 715ff3932bc6..9e8b3cf2effe 100644
--- a/tools/llvm-mc/AsmParser.cpp
+++ b/tools/llvm-mc/AsmParser.cpp
@@ -168,7 +168,9 @@ bool AsmParser::ParseX86MemOperand(X86Operand &Op) {
// memory operand consumed.
} else {
// It must be an parenthesized expression, parse it now.
- if (ParseParenExpr(Disp)) return true;
+ if (ParseParenExpr(Disp) ||
+ ParseBinOpRHS(1, Disp))
+ return true;
// After parsing the base expression we could either have a parenthesized
// memory address or not. If not, return now. If so, eat the (.
@@ -274,9 +276,61 @@ bool AsmParser::ParsePrimaryExpr(int64_t &Res) {
/// expr ::= primaryexpr
///
bool AsmParser::ParseExpression(int64_t &Res) {
- return ParsePrimaryExpr(Res);
+ return ParsePrimaryExpr(Res) ||
+ ParseBinOpRHS(1, Res);
}
-
+
+static unsigned getBinOpPrecedence(asmtok::TokKind K) {
+ switch (K) {
+ default: return 0; // not a binop.
+ case asmtok::Plus:
+ case asmtok::Minus:
+ return 1;
+ case asmtok::Pipe:
+ case asmtok::Caret:
+ case asmtok::Amp:
+ case asmtok::Exclaim:
+ return 2;
+ case asmtok::Star:
+ case asmtok::Slash:
+ case asmtok::Percent:
+ case asmtok::LessLess:
+ case asmtok::GreaterGreater:
+ return 3;
+ }
+}
+
+
+/// ParseBinOpRHS - Parse all binary operators with precedence >= 'Precedence'.
+/// Res contains the LHS of the expression on input.
+bool AsmParser::ParseBinOpRHS(unsigned Precedence, int64_t &Res) {
+ while (1) {
+ unsigned TokPrec = getBinOpPrecedence(Lexer.getKind());
+
+ // If the next token is lower precedence than we are allowed to eat, return
+ // successfully with what we ate already.
+ if (TokPrec < Precedence)
+ return false;
+
+ //asmtok::TokKind BinOp = Lexer.getKind();
+ Lexer.Lex();
+
+ // Eat the next primary expression.
+ int64_t RHS;
+ if (ParsePrimaryExpr(RHS)) return true;
+
+ // If BinOp binds less tightly with RHS than the operator after RHS, let
+ // the pending operator take RHS as its LHS.
+ unsigned NextTokPrec = getBinOpPrecedence(Lexer.getKind());
+ if (TokPrec < NextTokPrec) {
+ if (ParseBinOpRHS(Precedence+1, RHS)) return true;
+ }
+
+ // Merge LHS/RHS: fixme use the right operator etc.
+ Res += RHS;
+ }
+}
+
diff --git a/tools/llvm-mc/AsmParser.h b/tools/llvm-mc/AsmParser.h
index 82eb433b61ef..1dadb40ce2b8 100644
--- a/tools/llvm-mc/AsmParser.h
+++ b/tools/llvm-mc/AsmParser.h
@@ -40,6 +40,7 @@ private:
bool ParseX86MemOperand(X86Operand &Op);
bool ParseExpression(int64_t &Res);
bool ParsePrimaryExpr(int64_t &Res);
+ bool ParseBinOpRHS(unsigned Precedence, int64_t &Res);
bool ParseParenExpr(int64_t &Res);
};
diff --git a/tools/lto/LTOCodeGenerator.cpp b/tools/lto/LTOCodeGenerator.cpp
index 11e0e5551741..8db573e61fbf 100644
--- a/tools/lto/LTOCodeGenerator.cpp
+++ b/tools/lto/LTOCodeGenerator.cpp
@@ -290,6 +290,11 @@ bool LTOCodeGenerator::assemble(const std::string& asmPath,
args.push_back("-arch");
args.push_back("armv6");
}
+ else if ((strncmp(targetTriple.c_str(), "armv7-apple-", 12) == 0) ||
+ (strncmp(targetTriple.c_str(), "thumbv7-apple-", 14) == 0)) {
+ args.push_back("-arch");
+ args.push_back("armv7");
+ }
// add -static to assembler command line when code model requires
if ( (_assemblerPath != NULL) && (_codeModel == LTO_CODEGEN_PIC_MODEL_STATIC) )
args.push_back("-static");