//===----------------------------------------------------------------------===//
#include "LLParser.h"
+#include "llvm/ADT/DenseMap.h"
+#include "llvm/ADT/None.h"
+#include "llvm/ADT/Optional.h"
#include "llvm/ADT/SmallPtrSet.h"
#include "llvm/ADT/STLExtras.h"
-#include "llvm/ADT/StringExtras.h"
#include "llvm/AsmParser/SlotMapping.h"
+#include "llvm/IR/Argument.h"
#include "llvm/IR/AutoUpgrade.h"
+#include "llvm/IR/BasicBlock.h"
#include "llvm/IR/CallingConv.h"
-#include "llvm/IR/CallSite.h"
+#include "llvm/IR/Comdat.h"
#include "llvm/IR/Constants.h"
-#include "llvm/IR/DebugInfo.h"
#include "llvm/IR/DebugInfoMetadata.h"
#include "llvm/IR/DerivedTypes.h"
+#include "llvm/IR/Function.h"
+#include "llvm/IR/GlobalIFunc.h"
+#include "llvm/IR/GlobalObject.h"
#include "llvm/IR/InlineAsm.h"
+#include "llvm/IR/Instruction.h"
#include "llvm/IR/Instructions.h"
#include "llvm/IR/Intrinsics.h"
#include "llvm/IR/LLVMContext.h"
+#include "llvm/IR/Metadata.h"
#include "llvm/IR/Module.h"
#include "llvm/IR/Operator.h"
+#include "llvm/IR/Type.h"
+#include "llvm/IR/Value.h"
#include "llvm/IR/ValueSymbolTable.h"
-#include "llvm/Support/Debug.h"
+#include "llvm/Support/Casting.h"
#include "llvm/Support/Dwarf.h"
#include "llvm/Support/ErrorHandling.h"
+#include "llvm/Support/MathExtras.h"
#include "llvm/Support/SaveAndRestore.h"
#include "llvm/Support/raw_ostream.h"
+#include <algorithm>
+#include <cassert>
+#include <cstring>
+#include <iterator>
+#include <vector>
+
using namespace llvm;
static std::string getTypeString(Type *T) {
//===----------------------------------------------------------------------===//
bool LLParser::ParseTopLevelEntities() {
- while (1) {
+ while (true) {
switch (Lex.getKind()) {
default: return TokError("expected top-level entity");
case lltok::Eof: return false;
}
}
-
/// toplevelentity
/// ::= 'module' 'asm' STRINGCONSTANT
bool LLParser::ParseModuleAsm() {
return false;
}
-
/// toplevelentity
/// ::= LocalVar '=' 'type' type
bool LLParser::ParseNamedType() {
return false;
}
-
/// toplevelentity
/// ::= 'declare' FunctionHeader
bool LLParser::ParseDeclare() {
return FwdVal;
}
-
//===----------------------------------------------------------------------===//
// Comdat Reference/Resolution Routines.
//===----------------------------------------------------------------------===//
return C;
}
-
//===----------------------------------------------------------------------===//
// Helper Routines.
//===----------------------------------------------------------------------===//
B.clear();
- while (1) {
+ while (true) {
lltok::Kind Token = Lex.getKind();
switch (Token) {
default: // End of attributes.
B.clear();
- while (1) {
+ while (true) {
lltok::Kind Token = Lex.getKind();
switch (Token) {
default: // End of attributes.
}
// Parse the type suffixes.
- while (1) {
+ while (true) {
switch (Lex.getKind()) {
// End of type.
default:
return false;
}
-
/// ParseStructType: Handles packed and unpacked types. </> parsed elsewhere.
/// StructType
/// ::= '{' '}'
return false;
}
-
/// 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.
MDUnsignedField(uint64_t Default = 0, uint64_t Max = UINT64_MAX)
: ImplTy(Default), Max(Max) {}
};
+
struct LineField : public MDUnsignedField {
LineField() : MDUnsignedField(0, UINT32_MAX) {}
};
+
struct ColumnField : public MDUnsignedField {
ColumnField() : MDUnsignedField(0, UINT16_MAX) {}
};
+
struct DwarfTagField : public MDUnsignedField {
DwarfTagField() : MDUnsignedField(0, dwarf::DW_TAG_hi_user) {}
DwarfTagField(dwarf::Tag DefaultTag)
: MDUnsignedField(DefaultTag, dwarf::DW_TAG_hi_user) {}
};
+
struct DwarfMacinfoTypeField : public MDUnsignedField {
DwarfMacinfoTypeField() : MDUnsignedField(0, dwarf::DW_MACINFO_vendor_ext) {}
DwarfMacinfoTypeField(dwarf::MacinfoRecordType DefaultType)
: MDUnsignedField(DefaultType, dwarf::DW_MACINFO_vendor_ext) {}
};
+
struct DwarfAttEncodingField : public MDUnsignedField {
DwarfAttEncodingField() : MDUnsignedField(0, dwarf::DW_ATE_hi_user) {}
};
+
struct DwarfVirtualityField : public MDUnsignedField {
DwarfVirtualityField() : MDUnsignedField(0, dwarf::DW_VIRTUALITY_max) {}
};
+
struct DwarfLangField : public MDUnsignedField {
DwarfLangField() : MDUnsignedField(0, dwarf::DW_LANG_hi_user) {}
};
+
struct DwarfCCField : public MDUnsignedField {
DwarfCCField() : MDUnsignedField(0, dwarf::DW_CC_hi_user) {}
};
+
struct EmissionKindField : public MDUnsignedField {
EmissionKindField() : MDUnsignedField(0, DICompileUnit::LastEmissionKind) {}
};
struct MDBoolField : public MDFieldImpl<bool> {
MDBoolField(bool Default = false) : ImplTy(Default) {}
};
+
struct MDField : public MDFieldImpl<Metadata *> {
bool AllowNull;
MDField(bool AllowNull = true) : ImplTy(nullptr), AllowNull(AllowNull) {}
};
+
struct MDConstant : public MDFieldImpl<ConstantAsMetadata *> {
MDConstant() : ImplTy(nullptr) {}
};
+
struct MDStringField : public MDFieldImpl<MDString *> {
bool AllowEmpty;
MDStringField(bool AllowEmpty = true)
: ImplTy(nullptr), AllowEmpty(AllowEmpty) {}
};
+
struct MDFieldList : public MDFieldImpl<SmallVector<Metadata *, 4>> {
MDFieldList() : ImplTy(SmallVector<Metadata *, 4>()) {}
};
-} // end namespace
+} // end anonymous namespace
namespace llvm {
return false;
}
-
/// ParseDIModule:
/// ::= !DIModule(scope: !0, name: "SomeModule", configMacros: "-DNDEBUG",
/// includePath: "/usr/include", isysroot: "/")
return false;
}
-
//===----------------------------------------------------------------------===//
// Function Parsing.
//===----------------------------------------------------------------------===//
return false;
}
-
/// FunctionHeader
/// ::= OptionalLinkage OptionalVisibility OptionalCallingConv OptRetAttrs
/// OptUnnamedAddr Type GlobalName '(' ArgList ')' OptFuncAttrs OptSection
return false;
}
-
/// ParseBr
/// ::= 'br' TypeAndValue
/// ::= 'br' TypeAndValue ',' TypeAndValue ',' TypeAndValue
return false;
}
-
/// ParseInvoke
/// ::= 'invoke' OptionalCallingConv OptionalAttrs Type Value ParamList
/// OptionalAttrs 'to' TypeAndValue 'unwind' TypeAndValue
return false;
}
-
/// ParseCompare
/// ::= 'icmp' IPredicates TypeAndValue ',' Value
/// ::= 'fcmp' FPredicates TypeAndValue ',' Value
bool AteExtraComma = false;
SmallVector<std::pair<Value*, BasicBlock*>, 16> PHIVals;
- while (1) {
+
+ while (true) {
PHIVals.push_back(std::make_pair(Op0, cast<BasicBlock>(Op1)));
if (!EatIfPresent(lltok::comma))