LLVM  4.0.0
Macros | Functions | Variables
LLParser.cpp File Reference
#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/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/Comdat.h"
#include "llvm/IR/Constants.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/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>
#include "llvm/IR/Metadata.def"
Include dependency graph for LLParser.cpp:

Go to the source code of this file.

Macros

#define HANDLE_SPECIALIZED_MDNODE_LEAF(CLASS)
 
#define DECLARE_FIELD(NAME, TYPE, INIT)   TYPE NAME INIT
 
#define NOP_FIELD(NAME, TYPE, INIT)
 
#define REQUIRE_FIELD(NAME, TYPE, INIT)
 
#define PARSE_MD_FIELD(NAME, TYPE, DEFAULT)
 
#define PARSE_MD_FIELDS()
 
#define GET_OR_DISTINCT(CLASS, ARGS)   (IsDistinct ? CLASS::getDistinct ARGS : CLASS::get ARGS)
 
#define VISIT_MD_FIELDS(OPTIONAL, REQUIRED)
 
#define VISIT_MD_FIELDS(OPTIONAL, REQUIRED)
 
#define VISIT_MD_FIELDS(OPTIONAL, REQUIRED)
 
#define VISIT_MD_FIELDS(OPTIONAL, REQUIRED)
 
#define VISIT_MD_FIELDS(OPTIONAL, REQUIRED)
 
#define VISIT_MD_FIELDS(OPTIONAL, REQUIRED)
 
#define VISIT_MD_FIELDS(OPTIONAL, REQUIRED)
 
#define VISIT_MD_FIELDS(OPTIONAL, REQUIRED)
 
#define VISIT_MD_FIELDS(OPTIONAL, REQUIRED)
 
#define VISIT_MD_FIELDS(OPTIONAL, REQUIRED)
 
#define VISIT_MD_FIELDS(OPTIONAL, REQUIRED)
 
#define VISIT_MD_FIELDS(OPTIONAL, REQUIRED)
 
#define VISIT_MD_FIELDS(OPTIONAL, REQUIRED)
 
#define VISIT_MD_FIELDS(OPTIONAL, REQUIRED)
 
#define VISIT_MD_FIELDS(OPTIONAL, REQUIRED)
 
#define VISIT_MD_FIELDS(OPTIONAL, REQUIRED)
 
#define VISIT_MD_FIELDS(OPTIONAL, REQUIRED)
 
#define VISIT_MD_FIELDS(OPTIONAL, REQUIRED)
 
#define VISIT_MD_FIELDS(OPTIONAL, REQUIRED)
 
#define VISIT_MD_FIELDS(OPTIONAL, REQUIRED)
 
#define VISIT_MD_FIELDS(OPTIONAL, REQUIRED)
 
#define VISIT_MD_FIELDS(OPTIONAL, REQUIRED)
 
#define VISIT_MD_FIELDS(OPTIONAL, REQUIRED)
 
#define VISIT_MD_FIELDS(OPTIONAL, REQUIRED)
 

Functions

static std::string getTypeString (Type *T)
 
static bool isValidVisibilityForLinkage (unsigned V, unsigned L)
 
static GlobalValuecreateGlobalFwdRef (Module *M, PointerType *PTy, const std::string &Name)
 
if (!EatIfPresent(lltok::kw_thread_local)) return false
 ParseOptionalThreadLocal := /*empty. More...
 
 if (Lex.getKind()==lltok::lparen)
 
if (!EatIfPresent(lltok::kw_addrspace)) return false
 ParseOptionalAddrSpace := /*empty. More...
 
static unsigned parseOptionalLinkageAux (lltok::Kind Kind, bool &HasLinkage)
 
 F (f)
 
 FunctionNumber (functionNumber)
 

Variables

 TLM = GlobalVariable::GeneralDynamicTLSModel
 
return false
 

Macro Definition Documentation

#define DECLARE_FIELD (   NAME,
  TYPE,
  INIT 
)    TYPE NAME INIT
#define GET_OR_DISTINCT (   CLASS,
  ARGS 
)    (IsDistinct ? CLASS::getDistinct ARGS : CLASS::get ARGS)
#define HANDLE_SPECIALIZED_MDNODE_LEAF (   CLASS)
Value:
if (Lex.getStrVal() == #CLASS) \
return Parse##CLASS(N, IsDistinct);
#define N
#define NOP_FIELD (   NAME,
  TYPE,
  INIT 
)
#define PARSE_MD_FIELD (   NAME,
  TYPE,
  DEFAULT 
)
Value:
if (Lex.getStrVal() == #NAME) \
return ParseMDField(#NAME, NAME);
#define PARSE_MD_FIELDS ( )
Value:
do { \
LocTy ClosingLoc; \
if (ParseMDFieldsImpl([&]() -> bool { \
return TokError(Twine("invalid field '") + Lex.getStrVal() + "'"); \
}, ClosingLoc)) \
return true; \
} while (false)
#define DECLARE_FIELD(NAME, TYPE, INIT)
#define REQUIRE_FIELD(NAME, TYPE, INIT)
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Definition: Twine.h:81
#define NOP_FIELD(NAME, TYPE, INIT)
* if(!EatIfPresent(lltok::kw_thread_local)) return false
ParseOptionalThreadLocal := /*empty.
#define VISIT_MD_FIELDS(OPTIONAL, REQUIRED)
#define PARSE_MD_FIELD(NAME, TYPE, DEFAULT)
#define REQUIRE_FIELD (   NAME,
  TYPE,
  INIT 
)
Value:
if (!NAME.Seen) \
return Error(ClosingLoc, "missing required field '" #NAME "'");
#define VISIT_MD_FIELDS (   OPTIONAL,
  REQUIRED 
)
Value:
OPTIONAL(line, LineField, ); \
OPTIONAL(column, ColumnField, ); \
REQUIRED(scope, MDField, (/* AllowNull */ false)); \
OPTIONAL(inlinedAt, MDField, );
#define VISIT_MD_FIELDS (   OPTIONAL,
  REQUIRED 
)
Value:
REQUIRED(tag, DwarfTagField, ); \
OPTIONAL(header, MDStringField, ); \
OPTIONAL(operands, MDFieldList, );
#define VISIT_MD_FIELDS (   OPTIONAL,
  REQUIRED 
)
Value:
REQUIRED(count, MDSignedField, (-1, -1, INT64_MAX)); \
OPTIONAL(lowerBound, MDSignedField, );
auto count(R &&Range, const E &Element) -> typename std::iterator_traits< decltype(std::begin(Range))>::difference_type
Wrapper function around std::count to count the number of times an element Element occurs in the give...
Definition: STLExtras.h:791
#define VISIT_MD_FIELDS (   OPTIONAL,
  REQUIRED 
)
Value:
REQUIRED(name, MDStringField, ); \
REQUIRED(value, MDSignedField, );
static const char * name
#define VISIT_MD_FIELDS (   OPTIONAL,
  REQUIRED 
)
Value:
OPTIONAL(tag, DwarfTagField, (dwarf::DW_TAG_base_type)); \
OPTIONAL(name, MDStringField, ); \
OPTIONAL(size, MDUnsignedField, (0, UINT64_MAX)); \
OPTIONAL(align, MDUnsignedField, (0, UINT32_MAX)); \
OPTIONAL(encoding, DwarfAttEncodingField, );
static const char * name
#define VISIT_MD_FIELDS (   OPTIONAL,
  REQUIRED 
)
Value:
REQUIRED(tag, DwarfTagField, ); \
OPTIONAL(name, MDStringField, ); \
OPTIONAL(file, MDField, ); \
OPTIONAL(line, LineField, ); \
OPTIONAL(scope, MDField, ); \
REQUIRED(baseType, MDField, ); \
OPTIONAL(size, MDUnsignedField, (0, UINT64_MAX)); \
OPTIONAL(align, MDUnsignedField, (0, UINT32_MAX)); \
OPTIONAL(offset, MDUnsignedField, (0, UINT64_MAX)); \
OPTIONAL(flags, DIFlagField, ); \
OPTIONAL(extraData, MDField, );
dot regions Print regions of function to dot file(with no function bodies)"
static const char * name
#define VISIT_MD_FIELDS (   OPTIONAL,
  REQUIRED 
)
Value:
REQUIRED(tag, DwarfTagField, ); \
OPTIONAL(name, MDStringField, ); \
OPTIONAL(file, MDField, ); \
OPTIONAL(line, LineField, ); \
OPTIONAL(scope, MDField, ); \
OPTIONAL(baseType, MDField, ); \
OPTIONAL(size, MDUnsignedField, (0, UINT64_MAX)); \
OPTIONAL(align, MDUnsignedField, (0, UINT32_MAX)); \
OPTIONAL(offset, MDUnsignedField, (0, UINT64_MAX)); \
OPTIONAL(flags, DIFlagField, ); \
OPTIONAL(elements, MDField, ); \
OPTIONAL(runtimeLang, DwarfLangField, ); \
OPTIONAL(vtableHolder, MDField, ); \
OPTIONAL(templateParams, MDField, ); \
OPTIONAL(identifier, MDStringField, );
dot regions Print regions of function to dot file(with no function bodies)"
static const char * name
#define VISIT_MD_FIELDS (   OPTIONAL,
  REQUIRED 
)
Value:
OPTIONAL(flags, DIFlagField, ); \
OPTIONAL(cc, DwarfCCField, ); \
REQUIRED(types, MDField, );
#define VISIT_MD_FIELDS (   OPTIONAL,
  REQUIRED 
)
Value:
REQUIRED(filename, MDStringField, ); \
REQUIRED(directory, MDStringField, ); \
OPTIONAL(checksumkind, ChecksumKindField, ); \
OPTIONAL(checksum, MDStringField, );
StringRef filename(StringRef path)
Get filename.
Definition: Path.cpp:584
#define VISIT_MD_FIELDS (   OPTIONAL,
  REQUIRED 
)
Value:
REQUIRED(language, DwarfLangField, ); \
REQUIRED(file, MDField, (/* AllowNull */ false)); \
OPTIONAL(producer, MDStringField, ); \
OPTIONAL(isOptimized, MDBoolField, ); \
OPTIONAL(flags, MDStringField, ); \
OPTIONAL(runtimeVersion, MDUnsignedField, (0, UINT32_MAX)); \
OPTIONAL(splitDebugFilename, MDStringField, ); \
OPTIONAL(emissionKind, EmissionKindField, ); \
OPTIONAL(enums, MDField, ); \
OPTIONAL(retainedTypes, MDField, ); \
OPTIONAL(globals, MDField, ); \
OPTIONAL(imports, MDField, ); \
OPTIONAL(macros, MDField, ); \
OPTIONAL(dwoId, MDUnsignedField, ); \
OPTIONAL(splitDebugInlining, MDBoolField, = true);
dot regions Print regions of function to dot file(with no function bodies)"
name anon globals
#define VISIT_MD_FIELDS (   OPTIONAL,
  REQUIRED 
)
Value:
OPTIONAL(scope, MDField, ); \
OPTIONAL(name, MDStringField, ); \
OPTIONAL(linkageName, MDStringField, ); \
OPTIONAL(file, MDField, ); \
OPTIONAL(line, LineField, ); \
OPTIONAL(type, MDField, ); \
OPTIONAL(isLocal, MDBoolField, ); \
OPTIONAL(isDefinition, MDBoolField, (true)); \
OPTIONAL(scopeLine, LineField, ); \
OPTIONAL(containingType, MDField, ); \
OPTIONAL(virtuality, DwarfVirtualityField, ); \
OPTIONAL(virtualIndex, MDUnsignedField, (0, UINT32_MAX)); \
OPTIONAL(thisAdjustment, MDSignedField, (0, INT32_MIN, INT32_MAX)); \
OPTIONAL(flags, DIFlagField, ); \
OPTIONAL(isOptimized, MDBoolField, ); \
OPTIONAL(unit, MDField, ); \
OPTIONAL(templateParams, MDField, ); \
OPTIONAL(declaration, MDField, ); \
OPTIONAL(variables, MDField, );
global Merge global variables
dot regions Print regions of function to dot file(with no function bodies)"
static const char * name
#define VISIT_MD_FIELDS (   OPTIONAL,
  REQUIRED 
)
Value:
REQUIRED(scope, MDField, (/* AllowNull */ false)); \
OPTIONAL(file, MDField, ); \
OPTIONAL(line, LineField, ); \
OPTIONAL(column, ColumnField, );
dot regions Print regions of function to dot file(with no function bodies)"
#define VISIT_MD_FIELDS (   OPTIONAL,
  REQUIRED 
)
Value:
REQUIRED(scope, MDField, (/* AllowNull */ false)); \
OPTIONAL(file, MDField, ); \
REQUIRED(discriminator, MDUnsignedField, (0, UINT32_MAX));
dot regions Print regions of function to dot file(with no function bodies)"
#define VISIT_MD_FIELDS (   OPTIONAL,
  REQUIRED 
)
Value:
REQUIRED(scope, MDField, ); \
OPTIONAL(file, MDField, ); \
OPTIONAL(name, MDStringField, ); \
OPTIONAL(line, LineField, ); \
OPTIONAL(exportSymbols, MDBoolField, );
dot regions Print regions of function to dot file(with no function bodies)"
static const char * name
#define VISIT_MD_FIELDS (   OPTIONAL,
  REQUIRED 
)
Value:
REQUIRED(type, DwarfMacinfoTypeField, ); \
OPTIONAL(line, LineField, ); \
REQUIRED(name, MDStringField, ); \
OPTIONAL(value, MDStringField, );
static const char * name
#define VISIT_MD_FIELDS (   OPTIONAL,
  REQUIRED 
)
Value:
OPTIONAL(type, DwarfMacinfoTypeField, (dwarf::DW_MACINFO_start_file)); \
OPTIONAL(line, LineField, ); \
REQUIRED(file, MDField, ); \
OPTIONAL(nodes, MDField, );
dot regions Print regions of function to dot file(with no function bodies)"
#define VISIT_MD_FIELDS (   OPTIONAL,
  REQUIRED 
)
Value:
REQUIRED(scope, MDField, ); \
REQUIRED(name, MDStringField, ); \
OPTIONAL(configMacros, MDStringField, ); \
OPTIONAL(includePath, MDStringField, ); \
OPTIONAL(isysroot, MDStringField, );
static const char * name
#define VISIT_MD_FIELDS (   OPTIONAL,
  REQUIRED 
)
Value:
OPTIONAL(name, MDStringField, ); \
REQUIRED(type, MDField, );
static const char * name
#define VISIT_MD_FIELDS (   OPTIONAL,
  REQUIRED 
)
Value:
OPTIONAL(tag, DwarfTagField, (dwarf::DW_TAG_template_value_parameter)); \
OPTIONAL(name, MDStringField, ); \
OPTIONAL(type, MDField, ); \
REQUIRED(value, MDField, );
static const char * name
#define VISIT_MD_FIELDS (   OPTIONAL,
  REQUIRED 
)
Value:
REQUIRED(name, MDStringField, (/* AllowEmpty */ false)); \
OPTIONAL(scope, MDField, ); \
OPTIONAL(linkageName, MDStringField, ); \
OPTIONAL(file, MDField, ); \
OPTIONAL(line, LineField, ); \
OPTIONAL(type, MDField, ); \
OPTIONAL(isLocal, MDBoolField, ); \
OPTIONAL(isDefinition, MDBoolField, (true)); \
OPTIONAL(declaration, MDField, ); \
OPTIONAL(align, MDUnsignedField, (0, UINT32_MAX));
dot regions Print regions of function to dot file(with no function bodies)"
static const char * name
#define VISIT_MD_FIELDS (   OPTIONAL,
  REQUIRED 
)
Value:
REQUIRED(scope, MDField, (/* AllowNull */ false)); \
OPTIONAL(name, MDStringField, ); \
OPTIONAL(arg, MDUnsignedField, (0, UINT16_MAX)); \
OPTIONAL(file, MDField, ); \
OPTIONAL(line, LineField, ); \
OPTIONAL(type, MDField, ); \
OPTIONAL(flags, DIFlagField, ); \
OPTIONAL(align, MDUnsignedField, (0, UINT32_MAX));
dot regions Print regions of function to dot file(with no function bodies)"
static const char * name
#define VISIT_MD_FIELDS (   OPTIONAL,
  REQUIRED 
)
Value:
REQUIRED(var, MDField, ); \
OPTIONAL(expr, MDField, );
#define VISIT_MD_FIELDS (   OPTIONAL,
  REQUIRED 
)
Value:
OPTIONAL(name, MDStringField, ); \
OPTIONAL(file, MDField, ); \
OPTIONAL(line, LineField, ); \
OPTIONAL(setter, MDStringField, ); \
OPTIONAL(getter, MDStringField, ); \
OPTIONAL(attributes, MDUnsignedField, (0, UINT32_MAX)); \
OPTIONAL(type, MDField, );
dot regions Print regions of function to dot file(with no function bodies)"
Deduce function attributes
static const char * name
#define VISIT_MD_FIELDS (   OPTIONAL,
  REQUIRED 
)
Value:
REQUIRED(tag, DwarfTagField, ); \
REQUIRED(scope, MDField, ); \
OPTIONAL(entity, MDField, ); \
OPTIONAL(line, LineField, ); \
OPTIONAL(name, MDStringField, );
static const char * name

Function Documentation

static GlobalValue* createGlobalFwdRef ( Module M,
PointerType PTy,
const std::string &  Name 
)
inlinestatic
F ( )
FunctionNumber ( functionNumber  )

Definition at line 2459 of file LLParser.cpp.

References A, and llvm::Function::args().

Referenced by PrintParentLoopComment().

static std::string getTypeString ( Type T)
static

Definition at line 57 of file LLParser.cpp.

References llvm::raw_string_ostream::str(), and T.

* if ( EatIfPresentlltok::kw_thread_local)

ParseOptionalThreadLocal := /*empty.

Referenced by allocset(), analyzeGlobalAux(), llvm::MachineOperandIteratorBase::analyzeVirtReg(), llvm::computeBlockSize(), llvm::RegisterClassInfo::computePSetLimit(), llvm::TargetInstrInfo::defaultDefLatency(), llvm::OrderedBasicBlock::dominates(), llvm::DWARFAcceleratorTable::dump(), llvm::MCDwarfLineAddr::Encode(), llvm::PMDataManager::findAnalysisPass(), FindLIVLoopCondition(), llvm::RuntimeDyldImpl::findOrEmitSection(), gatherUnrollingPreferences(), llvm::X86TTIImpl::getArithmeticInstrCost(), llvm::X86TTIImpl::getCmpSelInstrCost(), llvm::ARMConstantPoolValue::getExistingMachineCPValueImpl(), llvm::DWARFDebugLine::LineTable::getFileNameByIndex(), llvm::getInlineParams(), llvm::DWARFContext::getInliningInfoForAddress(), llvm::X86TTIImpl::getIntrinsicInstrCost(), llvm::PPCTTIImpl::getMemoryOpCost(), llvm::LexicalScopes::getOrCreateAbstractScope(), llvm::SparseSolver::getOrInitValueState(), llvm::X86TTIImpl::getReductionCost(), llvm::X86TargetLowering::getRegForInlineAsmConstraint(), llvm::orc::rpc::detail::RPCEndpointBase< SingleThreadedRPCEndpoint< ChannelT, FunctionIdT, SequenceNumberT >, ChannelT, FunctionIdT, SequenceNumberT >::getRemoteFunctionId(), llvm::MachineTraceMetrics::getResources(), llvm::isGuaranteedToExecute(), llvm::GVN::ValueTable::lookupOrAdd(), llvm::DWARFDebugLoc::parse(), llvm::FastISel::selectExtractValue(), llvm::ExecutionEngine::StoreValueToMemory(), translateImmediate(), llvm::ConstantRange::unionWith(), and llvm::MachObjectWriter::writeNlist().

if ( Lex.  getKind() = = lltok::lparen)

Definition at line 1330 of file LLParser.cpp.

References llvm::LLLexer::Lex(), and llvm::lltok::rparen.

* if ( EatIfPresentlltok::kw_addrspace)

ParseOptionalAddrSpace := /*empty.

static bool isValidVisibilityForLinkage ( unsigned  V,
unsigned  L 
)
static
static unsigned parseOptionalLinkageAux ( lltok::Kind  Kind,
bool HasLinkage 
)
static

Variable Documentation

return false

Definition at line 1335 of file LLParser.cpp.

TLM = GlobalVariable::GeneralDynamicTLSModel

Definition at line 1329 of file LLParser.cpp.