mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-01-31 12:41:49 +01:00
Down with trailing whitespace!
llvm-svn: 61594
This commit is contained in:
parent
1969e75214
commit
8d90975ba9
@ -25,20 +25,20 @@ using namespace llvm;
|
||||
bool LLLexer::Error(LocTy ErrorLoc, const std::string &Msg) const {
|
||||
// Scan backward to find the start of the line.
|
||||
const char *LineStart = ErrorLoc;
|
||||
while (LineStart != CurBuf->getBufferStart() &&
|
||||
while (LineStart != CurBuf->getBufferStart() &&
|
||||
LineStart[-1] != '\n' && LineStart[-1] != '\r')
|
||||
--LineStart;
|
||||
// Get the end of the line.
|
||||
const char *LineEnd = ErrorLoc;
|
||||
while (LineEnd != CurBuf->getBufferEnd() &&
|
||||
while (LineEnd != CurBuf->getBufferEnd() &&
|
||||
LineEnd[0] != '\n' && LineEnd[0] != '\r')
|
||||
++LineEnd;
|
||||
|
||||
|
||||
unsigned LineNo = 1;
|
||||
for (const char *FP = CurBuf->getBufferStart(); FP != ErrorLoc; ++FP)
|
||||
if (*FP == '\n') ++LineNo;
|
||||
|
||||
std::string LineContents(LineStart, LineEnd);
|
||||
std::string LineContents(LineStart, LineEnd);
|
||||
ErrorInfo.setError(Msg, LineNo, ErrorLoc-LineStart, LineContents);
|
||||
return true;
|
||||
}
|
||||
@ -519,7 +519,7 @@ lltok::Kind LLLexer::LexIdentifier() {
|
||||
KEYWORD(sge); KEYWORD(ult); KEYWORD(ugt); KEYWORD(ule); KEYWORD(uge);
|
||||
KEYWORD(oeq); KEYWORD(one); KEYWORD(olt); KEYWORD(ogt); KEYWORD(ole);
|
||||
KEYWORD(oge); KEYWORD(ord); KEYWORD(uno); KEYWORD(ueq); KEYWORD(une);
|
||||
|
||||
|
||||
KEYWORD(x);
|
||||
#undef KEYWORD
|
||||
|
||||
|
@ -26,7 +26,7 @@ namespace llvm {
|
||||
class MemoryBuffer;
|
||||
class Type;
|
||||
class ParseError;
|
||||
|
||||
|
||||
class LLLexer {
|
||||
const char *CurPtr;
|
||||
MemoryBuffer *CurBuf;
|
||||
@ -40,7 +40,7 @@ namespace llvm {
|
||||
const Type *TyVal;
|
||||
APFloat APFloatVal;
|
||||
APSInt APSIntVal;
|
||||
|
||||
|
||||
std::string TheError;
|
||||
public:
|
||||
explicit LLLexer(MemoryBuffer *StartBuf, ParseError &);
|
||||
@ -59,11 +59,11 @@ namespace llvm {
|
||||
const APSInt &getAPSIntVal() const { return APSIntVal; }
|
||||
const APFloat &getAPFloatVal() const { return APFloatVal; }
|
||||
|
||||
|
||||
|
||||
bool Error(LocTy L, const std::string &Msg) const;
|
||||
bool Error(const std::string &Msg) const { return Error(CurPtr, Msg); }
|
||||
std::string getFilename() const;
|
||||
|
||||
|
||||
private:
|
||||
lltok::Kind LexToken();
|
||||
|
||||
@ -76,7 +76,7 @@ namespace llvm {
|
||||
lltok::Kind LexPercent();
|
||||
lltok::Kind LexQuote();
|
||||
lltok::Kind Lex0x();
|
||||
|
||||
|
||||
uint64_t atoull(const char *Buffer, const char *End);
|
||||
uint64_t HexIntToVal(const char *Buffer, const char *End);
|
||||
void HexToIntPair(const char *Buffer, const char *End, uint64_t Pair[2]);
|
||||
|
@ -28,36 +28,36 @@ namespace llvm {
|
||||
class Constant;
|
||||
class GlobalValue;
|
||||
struct ValID;
|
||||
|
||||
|
||||
class LLParser {
|
||||
public:
|
||||
typedef LLLexer::LocTy LocTy;
|
||||
private:
|
||||
|
||||
|
||||
LLLexer Lex;
|
||||
Module *M;
|
||||
|
||||
|
||||
// Type resolution handling data structures.
|
||||
std::map<std::string, std::pair<PATypeHolder, LocTy> > ForwardRefTypes;
|
||||
std::map<unsigned, std::pair<PATypeHolder, LocTy> > ForwardRefTypeIDs;
|
||||
std::vector<PATypeHolder> NumberedTypes;
|
||||
|
||||
|
||||
struct UpRefRecord {
|
||||
/// Loc - This is the location of the upref.
|
||||
LocTy Loc;
|
||||
|
||||
|
||||
/// NestingLevel - The number of nesting levels that need to be popped
|
||||
/// before this type is resolved.
|
||||
unsigned NestingLevel;
|
||||
|
||||
|
||||
/// LastContainedTy - This is the type at the current binding level for
|
||||
/// the type. Every time we reduce the nesting level, this gets updated.
|
||||
const Type *LastContainedTy;
|
||||
|
||||
|
||||
/// UpRefTy - This is the actual opaque type that the upreference is
|
||||
/// represented with.
|
||||
OpaqueType *UpRefTy;
|
||||
|
||||
|
||||
UpRefRecord(LocTy L, unsigned NL, OpaqueType *URTy)
|
||||
: Loc(L), NestingLevel(NL), LastContainedTy((Type*)URTy),
|
||||
UpRefTy(URTy) {}
|
||||
@ -71,7 +71,7 @@ namespace llvm {
|
||||
public:
|
||||
LLParser(MemoryBuffer *F, ParseError &Err) : Lex(F, Err), M(0) {}
|
||||
Module *Run();
|
||||
|
||||
|
||||
private:
|
||||
|
||||
bool Error(LocTy L, const std::string &Msg) const {
|
||||
@ -80,13 +80,13 @@ namespace llvm {
|
||||
bool TokError(const std::string &Msg) const {
|
||||
return Error(Lex.getLoc(), Msg);
|
||||
}
|
||||
|
||||
|
||||
/// GetGlobalVal - Get a value with the specified name or ID, creating a
|
||||
/// forward reference record if needed. This can return null if the value
|
||||
/// exists but does not have the right type.
|
||||
GlobalValue *GetGlobalVal(const std::string &N, const Type *Ty, LocTy Loc);
|
||||
GlobalValue *GetGlobalVal(unsigned ID, const Type *Ty, LocTy Loc);
|
||||
|
||||
|
||||
// Helper Routines.
|
||||
bool ParseToken(lltok::Kind T, const char *ErrMsg);
|
||||
bool EatIfPresent(lltok::Kind T) {
|
||||
@ -120,7 +120,7 @@ namespace llvm {
|
||||
bool ParseOptionalAlignment(unsigned &Alignment);
|
||||
bool ParseOptionalCommaAlignment(unsigned &Alignment);
|
||||
bool ParseIndexList(SmallVectorImpl<unsigned> &Indices);
|
||||
|
||||
|
||||
// Top-Level Entities
|
||||
bool ParseTopLevelEntities();
|
||||
bool ValidateEndOfModule();
|
||||
@ -131,13 +131,13 @@ namespace llvm {
|
||||
bool ParseNamedType();
|
||||
bool ParseDeclare();
|
||||
bool ParseDefine();
|
||||
|
||||
|
||||
bool ParseGlobalType(bool &IsConstant);
|
||||
bool ParseNamedGlobal();
|
||||
bool ParseGlobal(const std::string &Name, LocTy Loc, unsigned Linkage,
|
||||
bool HasLinkage, unsigned Visibility);
|
||||
bool ParseAlias(const std::string &Name, LocTy Loc, unsigned Visibility);
|
||||
|
||||
|
||||
// Type Parsing.
|
||||
bool ParseType(PATypeHolder &Result);
|
||||
bool ParseType(PATypeHolder &Result, LocTy &Loc) {
|
||||
@ -157,7 +157,7 @@ namespace llvm {
|
||||
bool ParseGlobalTypeAndValue(Constant *&V);
|
||||
bool ParseGlobalValueVector(SmallVectorImpl<Constant*> &Elts);
|
||||
|
||||
|
||||
|
||||
// Function Semantic Analysis.
|
||||
class PerFunctionState {
|
||||
LLParser &P;
|
||||
@ -168,60 +168,60 @@ namespace llvm {
|
||||
public:
|
||||
PerFunctionState(LLParser &p, Function &f);
|
||||
~PerFunctionState();
|
||||
|
||||
|
||||
Function &getFunction() const { return F; }
|
||||
|
||||
|
||||
bool VerifyFunctionComplete();
|
||||
|
||||
|
||||
/// GetVal - Get a value with the specified name or ID, creating a
|
||||
/// forward reference record if needed. This can return null if the value
|
||||
/// exists but does not have the right type.
|
||||
Value *GetVal(const std::string &Name, const Type *Ty, LocTy Loc);
|
||||
Value *GetVal(unsigned ID, const Type *Ty, LocTy Loc);
|
||||
|
||||
|
||||
/// SetInstName - After an instruction is parsed and inserted into its
|
||||
/// basic block, this installs its name.
|
||||
bool SetInstName(int NameID, const std::string &NameStr, LocTy NameLoc,
|
||||
Instruction *Inst);
|
||||
|
||||
|
||||
/// GetBB - Get a basic block with the specified name or ID, creating a
|
||||
/// forward reference record if needed. This can return null if the value
|
||||
/// is not a BasicBlock.
|
||||
BasicBlock *GetBB(const std::string &Name, LocTy Loc);
|
||||
BasicBlock *GetBB(unsigned ID, LocTy Loc);
|
||||
|
||||
|
||||
/// DefineBB - Define the specified basic block, which is either named or
|
||||
/// unnamed. If there is an error, this returns null otherwise it returns
|
||||
/// the block being defined.
|
||||
BasicBlock *DefineBB(const std::string &Name, LocTy Loc);
|
||||
};
|
||||
|
||||
|
||||
bool ConvertValIDToValue(const Type *Ty, ValID &ID, Value *&V,
|
||||
PerFunctionState &PFS);
|
||||
|
||||
|
||||
bool ParseValue(const Type *Ty, Value *&V, PerFunctionState &PFS);
|
||||
bool ParseValue(const Type *Ty, Value *&V, LocTy &Loc,
|
||||
PerFunctionState &PFS) {
|
||||
Loc = Lex.getLoc();
|
||||
return ParseValue(Ty, V, PFS);
|
||||
}
|
||||
|
||||
|
||||
bool ParseTypeAndValue(Value *&V, PerFunctionState &PFS);
|
||||
bool ParseTypeAndValue(Value *&V, LocTy &Loc, PerFunctionState &PFS) {
|
||||
Loc = Lex.getLoc();
|
||||
return ParseTypeAndValue(V, PFS);
|
||||
}
|
||||
|
||||
|
||||
struct ParamInfo {
|
||||
LocTy Loc;
|
||||
Value *V;
|
||||
unsigned Attrs;
|
||||
ParamInfo(LocTy loc, Value *v, unsigned attrs)
|
||||
ParamInfo(LocTy loc, Value *v, unsigned attrs)
|
||||
: Loc(loc), V(v), Attrs(attrs) {}
|
||||
};
|
||||
bool ParseParameterList(SmallVectorImpl<ParamInfo> &ArgList,
|
||||
PerFunctionState &PFS);
|
||||
|
||||
|
||||
// Function Parsing.
|
||||
struct ArgInfo {
|
||||
LocTy Loc;
|
||||
@ -236,17 +236,17 @@ namespace llvm {
|
||||
bool ParseFunctionHeader(Function *&Fn, bool isDefine);
|
||||
bool ParseFunctionBody(Function &Fn);
|
||||
bool ParseBasicBlock(PerFunctionState &PFS);
|
||||
|
||||
|
||||
// Instruction Parsing.
|
||||
bool ParseInstruction(Instruction *&Inst, BasicBlock *BB,
|
||||
PerFunctionState &PFS);
|
||||
bool ParseCmpPredicate(unsigned &Pred, unsigned Opc);
|
||||
|
||||
|
||||
bool ParseRet(Instruction *&Inst, BasicBlock *BB, PerFunctionState &PFS);
|
||||
bool ParseBr(Instruction *&Inst, PerFunctionState &PFS);
|
||||
bool ParseSwitch(Instruction *&Inst, PerFunctionState &PFS);
|
||||
bool ParseInvoke(Instruction *&Inst, PerFunctionState &PFS);
|
||||
|
||||
|
||||
bool ParseArithmetic(Instruction *&I, PerFunctionState &PFS, unsigned Opc);
|
||||
bool ParseLogical(Instruction *&I, PerFunctionState &PFS, unsigned Opc);
|
||||
bool ParseCompare(Instruction *&I, PerFunctionState &PFS, unsigned Opc);
|
||||
|
@ -19,7 +19,7 @@ namespace lltok {
|
||||
enum Kind {
|
||||
// Markers
|
||||
Eof, Error,
|
||||
|
||||
|
||||
// Tokens with no info.
|
||||
dotdotdot, // ...
|
||||
equal, comma, // = ,
|
||||
@ -29,13 +29,13 @@ namespace lltok {
|
||||
less, greater, // < >
|
||||
lparen, rparen, // ( )
|
||||
backslash, // \ /
|
||||
|
||||
|
||||
kw_x,
|
||||
kw_begin, kw_end,
|
||||
kw_true, kw_false,
|
||||
kw_declare, kw_define,
|
||||
kw_global, kw_constant,
|
||||
|
||||
|
||||
kw_internal, kw_linkonce, kw_weak, kw_appending, kw_dllimport,
|
||||
kw_dllexport, kw_common, kw_default, kw_hidden, kw_protected,
|
||||
kw_extern_weak,
|
||||
@ -58,9 +58,9 @@ namespace lltok {
|
||||
kw_sideeffect,
|
||||
kw_gc,
|
||||
kw_c,
|
||||
|
||||
|
||||
kw_cc, kw_ccc, kw_fastcc, kw_coldcc, kw_x86_stdcallcc, kw_x86_fastcallcc,
|
||||
|
||||
|
||||
kw_signext,
|
||||
kw_zeroext,
|
||||
kw_inreg,
|
||||
@ -73,50 +73,50 @@ namespace lltok {
|
||||
kw_nest,
|
||||
kw_readnone,
|
||||
kw_readonly,
|
||||
|
||||
|
||||
kw_noinline,
|
||||
kw_alwaysinline,
|
||||
kw_optsize,
|
||||
kw_ssp,
|
||||
kw_sspreq,
|
||||
|
||||
|
||||
kw_type,
|
||||
kw_opaque,
|
||||
|
||||
|
||||
kw_eq, kw_ne, kw_slt, kw_sgt, kw_sle, kw_sge, kw_ult, kw_ugt, kw_ule,
|
||||
kw_uge, kw_oeq, kw_one, kw_olt, kw_ogt, kw_ole, kw_oge, kw_ord, kw_uno,
|
||||
kw_ueq, kw_une,
|
||||
|
||||
|
||||
// Instruction Opcodes (Opcode in UIntVal).
|
||||
kw_add, kw_sub, kw_mul, kw_udiv, kw_sdiv, kw_fdiv,
|
||||
kw_urem, kw_srem, kw_frem, kw_shl, kw_lshr, kw_ashr,
|
||||
kw_and, kw_or, kw_xor, kw_icmp, kw_fcmp, kw_vicmp, kw_vfcmp,
|
||||
|
||||
|
||||
kw_phi, kw_call,
|
||||
kw_trunc, kw_zext, kw_sext, kw_fptrunc, kw_fpext, kw_uitofp, kw_sitofp,
|
||||
kw_fptoui, kw_fptosi, kw_inttoptr, kw_ptrtoint, kw_bitcast,
|
||||
kw_select, kw_va_arg,
|
||||
|
||||
|
||||
kw_ret, kw_br, kw_switch, kw_invoke, kw_unwind, kw_unreachable,
|
||||
|
||||
|
||||
kw_malloc, kw_alloca, kw_free, kw_load, kw_store, kw_getelementptr,
|
||||
|
||||
|
||||
kw_extractelement, kw_insertelement, kw_shufflevector, kw_getresult,
|
||||
kw_extractvalue, kw_insertvalue,
|
||||
|
||||
|
||||
// Unsigned Valued tokens (UIntVal).
|
||||
GlobalID, // @42
|
||||
LocalVarID, // %42
|
||||
|
||||
|
||||
// String valued tokens (StrVal).
|
||||
LabelStr, // foo:
|
||||
GlobalVar, // @foo @"foo"
|
||||
LocalVar, // %foo %"foo"
|
||||
StringConstant, // "foo"
|
||||
|
||||
|
||||
// Type valued tokens (TyVal).
|
||||
Type,
|
||||
|
||||
Type,
|
||||
|
||||
APFloat, // APFloatVal
|
||||
APSInt // APSInt
|
||||
};
|
||||
|
@ -21,25 +21,25 @@ using namespace llvm;
|
||||
|
||||
Module *llvm::ParseAssemblyFile(const std::string &Filename, ParseError &Err) {
|
||||
Err.setFilename(Filename);
|
||||
|
||||
|
||||
std::string ErrorStr;
|
||||
MemoryBuffer *F = MemoryBuffer::getFileOrSTDIN(Filename.c_str(), &ErrorStr);
|
||||
if (F == 0) {
|
||||
Err.setError("Could not open input file '" + Filename + "'");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
Module *Result = LLParser(F, Err).Run();
|
||||
delete F;
|
||||
return Result;
|
||||
}
|
||||
|
||||
// FIXME: M is ignored??
|
||||
Module *llvm::ParseAssemblyString(const char *AsmString, Module *M,
|
||||
Module *llvm::ParseAssemblyString(const char *AsmString, Module *M,
|
||||
ParseError &Err) {
|
||||
Err.setFilename("<string>");
|
||||
|
||||
MemoryBuffer *F = MemoryBuffer::getMemBuffer(AsmString,
|
||||
MemoryBuffer *F = MemoryBuffer::getMemBuffer(AsmString,
|
||||
AsmString+strlen(AsmString),
|
||||
"<string>");
|
||||
Module *Result = LLParser(F, Err).Run();
|
||||
@ -58,22 +58,21 @@ void ParseError::PrintError(const char *ProgName, raw_ostream &S) {
|
||||
errs() << "<stdin>";
|
||||
else
|
||||
errs() << Filename;
|
||||
|
||||
|
||||
if (LineNo != -1) {
|
||||
errs() << ':' << LineNo;
|
||||
if (ColumnNo != -1)
|
||||
errs() << ':' << (ColumnNo+1);
|
||||
}
|
||||
|
||||
|
||||
errs() << ": " << Message << '\n';
|
||||
|
||||
|
||||
if (LineNo != -1 && ColumnNo != -1) {
|
||||
errs() << LineContents << '\n';
|
||||
|
||||
|
||||
// Print out spaces/tabs before the caret.
|
||||
for (unsigned i = 0; i != unsigned(ColumnNo); ++i)
|
||||
errs() << (LineContents[i] == '\t' ? '\t' : ' ');
|
||||
errs() << "^\n";
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user