LLVM  4.0.0
MIParser.h
Go to the documentation of this file.
1 //===- MIParser.h - Machine Instructions Parser ---------------------------===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file declares the function that parses the machine instructions.
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #ifndef LLVM_LIB_CODEGEN_MIRPARSER_MIPARSER_H
15 #define LLVM_LIB_CODEGEN_MIRPARSER_MIPARSER_H
16 
17 #include "llvm/ADT/DenseMap.h"
18 #include "llvm/ADT/SmallSet.h"
19 
20 namespace llvm {
21 
22 class StringRef;
23 class BasicBlock;
24 class MachineBasicBlock;
25 class MachineFunction;
26 class MachineInstr;
27 class MachineRegisterInfo;
28 class MDNode;
29 class RegisterBank;
30 struct SlotMapping;
31 class SMDiagnostic;
32 class SourceMgr;
33 class TargetRegisterClass;
34 
35 struct VRegInfo {
36  enum uint8_t {
38  } Kind = UNKNOWN;
39  bool Explicit = false; ///< VReg was explicitly specified in the .mir file.
40  union {
43  } D;
44  unsigned VReg;
45  unsigned PreferredReg = 0;
46 };
47 
53 
60 
62  const SlotMapping &IRSlots);
63 
64  VRegInfo &getVRegInfo(unsigned VReg);
65 };
66 
67 /// Parse the machine basic block definitions, and skip the machine
68 /// instructions.
69 ///
70 /// This function runs the first parsing pass on the machine function's body.
71 /// It parses only the machine basic block definitions and creates the machine
72 /// basic blocks in the given machine function.
73 ///
74 /// The machine instructions aren't parsed during the first pass because all
75 /// the machine basic blocks aren't defined yet - this makes it impossible to
76 /// resolve the machine basic block references.
77 ///
78 /// Return true if an error occurred.
81 
82 /// Parse the machine instructions.
83 ///
84 /// This function runs the second parsing pass on the machine function's body.
85 /// It skips the machine basic block definitions and parses only the machine
86 /// instructions and basic block attributes like liveins and successors.
87 ///
88 /// The second parsing pass assumes that the first parsing pass already ran
89 /// on the given source string.
90 ///
91 /// Return true if an error occurred.
94 
98 
100  unsigned &Reg, StringRef Src,
102 
105 
107  VRegInfo *&Info, StringRef Src,
109 
112 
115 
116 } // end namespace llvm
117 
118 #endif
bool parseMachineBasicBlockDefinitions(PerFunctionMIParsingState &PFS, StringRef Src, SMDiagnostic &Error)
Parse the machine basic block definitions, and skip the machine instructions.
Definition: MIParser.cpp:2257
DenseMap< unsigned, unsigned > JumpTableSlots
Definition: MIParser.h:59
DenseMap< unsigned, unsigned > ConstantPoolSlots
Definition: MIParser.h:58
Various leaf nodes.
Definition: ISDOpcodes.h:60
union llvm::VRegInfo::@253 D
DenseMap< unsigned, int > StackObjectSlots
Definition: MIParser.h:57
Metadata node.
Definition: Metadata.h:830
DenseMap< unsigned, VRegInfo * > VRegInfos
Definition: MIParser.h:55
bool parseMBBReference(PerFunctionMIParsingState &PFS, MachineBasicBlock *&MBB, StringRef Src, SMDiagnostic &Error)
Definition: MIParser.cpp:2268
const TargetRegisterClass * RC
Definition: MIParser.h:41
Reg
All possible values of the reg field in the ModR/M byte.
DenseMap< unsigned, int > FixedStackObjectSlots
Definition: MIParser.h:56
MachineBasicBlock * MBB
unsigned PreferredReg
Definition: MIParser.h:45
bool parseVirtualRegisterReference(PerFunctionMIParsingState &PFS, VRegInfo *&Info, StringRef Src, SMDiagnostic &Error)
Definition: MIParser.cpp:2286
VRegInfo & getVRegInfo(unsigned VReg)
Definition: MIParser.cpp:48
bool parseStackObjectReference(PerFunctionMIParsingState &PFS, int &FI, StringRef Src, SMDiagnostic &Error)
Definition: MIParser.cpp:2292
Allocate memory in an ever growing pool, as if by bump-pointer.
Definition: Allocator.h:138
PerFunctionMIParsingState(MachineFunction &MF, SourceMgr &SM, const SlotMapping &IRSlots)
Definition: MIParser.cpp:43
BumpPtrAllocator Allocator
Definition: MIParser.h:49
bool parseNamedRegisterReference(PerFunctionMIParsingState &PFS, unsigned &Reg, StringRef Src, SMDiagnostic &Error)
Definition: MIParser.cpp:2280
MachineFunction & MF
Definition: MIParser.h:50
This owns the files read by a parser, handles include stacks, and handles diagnostic wrangling...
Definition: SourceMgr.h:35
const SlotMapping & IRSlots
Definition: MIParser.h:52
bool parseMachineInstructions(PerFunctionMIParsingState &PFS, StringRef Src, SMDiagnostic &Error)
Parse the machine instructions.
Definition: MIParser.cpp:2263
enum llvm::VRegInfo::uint8_t Kind
This class implements the register bank concept.
Definition: RegisterBank.h:29
This struct contains the mappings from the slot numbers to unnamed metadata nodes, global values and types.
Definition: SlotMapping.h:33
bool parseMDNode(PerFunctionMIParsingState &PFS, MDNode *&Node, StringRef Src, SMDiagnostic &Error)
Definition: MIParser.cpp:2298
bool Explicit
VReg was explicitly specified in the .mir file.
Definition: MIParser.h:39
unsigned VReg
Definition: MIParser.h:44
DenseMap< unsigned, MachineBasicBlock * > MBBSlots
Definition: MIParser.h:54
Lightweight error class with error context and mandatory checking.
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:47
const RegisterBank * RegBank
Definition: MIParser.h:42
bool parseRegisterReference(PerFunctionMIParsingState &PFS, unsigned &Reg, StringRef Src, SMDiagnostic &Error)
Definition: MIParser.cpp:2274
Instances of this class encapsulate one diagnostic report, allowing printing to a raw_ostream as a ca...
Definition: SourceMgr.h:228