LLVM  5.0.0
MIParser.h
Go to the documentation of this file.
1 //===- MIParser.h - Machine Instructions Parser -----------------*- C++ -*-===//
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/StringMap.h"
19 #include "llvm/Support/Allocator.h"
20 
21 namespace llvm {
22 
23 class MachineBasicBlock;
24 class MachineFunction;
25 class MDNode;
26 class RegisterBank;
27 struct SlotMapping;
28 class SMDiagnostic;
29 class SourceMgr;
30 class StringRef;
31 class TargetRegisterClass;
32 
33 struct VRegInfo {
34  enum uint8_t {
36  } Kind = UNKNOWN;
37  bool Explicit = false; ///< VReg was explicitly specified in the .mir file.
38  union {
41  } D;
42  unsigned VReg;
43  unsigned PreferredReg = 0;
44 };
45 
48 
56 
63 
65  const SlotMapping &IRSlots,
68 
69  VRegInfo &getVRegInfo(unsigned VReg);
70 };
71 
72 /// Parse the machine basic block definitions, and skip the machine
73 /// instructions.
74 ///
75 /// This function runs the first parsing pass on the machine function's body.
76 /// It parses only the machine basic block definitions and creates the machine
77 /// basic blocks in the given machine function.
78 ///
79 /// The machine instructions aren't parsed during the first pass because all
80 /// the machine basic blocks aren't defined yet - this makes it impossible to
81 /// resolve the machine basic block references.
82 ///
83 /// Return true if an error occurred.
86 
87 /// Parse the machine instructions.
88 ///
89 /// This function runs the second parsing pass on the machine function's body.
90 /// It skips the machine basic block definitions and parses only the machine
91 /// instructions and basic block attributes like liveins and successors.
92 ///
93 /// The second parsing pass assumes that the first parsing pass already ran
94 /// on the given source string.
95 ///
96 /// Return true if an error occurred.
99 
101  MachineBasicBlock *&MBB, StringRef Src,
103 
105  unsigned &Reg, StringRef Src,
107 
110 
112  VRegInfo *&Info, StringRef Src,
114 
117 
120 
121 } // end namespace llvm
122 
123 #endif // LLVM_LIB_CODEGEN_MIRPARSER_MIPARSER_H
bool parseMachineBasicBlockDefinitions(PerFunctionMIParsingState &PFS, StringRef Src, SMDiagnostic &Error)
Parse the machine basic block definitions, and skip the machine instructions.
Definition: MIParser.cpp:2529
DenseMap< unsigned, unsigned > JumpTableSlots
Definition: MIParser.h:62
DenseMap< unsigned, unsigned > ConstantPoolSlots
Definition: MIParser.h:61
union llvm::VRegInfo::@284 D
DenseMap< unsigned, int > StackObjectSlots
Definition: MIParser.h:60
Metadata node.
Definition: Metadata.h:862
DenseMap< unsigned, VRegInfo * > VRegInfos
Definition: MIParser.h:58
bool parseMBBReference(PerFunctionMIParsingState &PFS, MachineBasicBlock *&MBB, StringRef Src, SMDiagnostic &Error)
Definition: MIParser.cpp:2540
const TargetRegisterClass * RC
Definition: MIParser.h:39
This file defines the MallocAllocator and BumpPtrAllocator interfaces.
Reg
All possible values of the reg field in the ModR/M byte.
const Name2RegBankMap & Names2RegBanks
Definition: MIParser.h:55
DenseMap< unsigned, int > FixedStackObjectSlots
Definition: MIParser.h:59
unsigned PreferredReg
Definition: MIParser.h:43
bool parseVirtualRegisterReference(PerFunctionMIParsingState &PFS, VRegInfo *&Info, StringRef Src, SMDiagnostic &Error)
Definition: MIParser.cpp:2558
VRegInfo & getVRegInfo(unsigned VReg)
Definition: MIParser.cpp:90
bool parseStackObjectReference(PerFunctionMIParsingState &PFS, int &FI, StringRef Src, SMDiagnostic &Error)
Definition: MIParser.cpp:2564
Allocate memory in an ever growing pool, as if by bump-pointer.
Definition: Allocator.h:138
BumpPtrAllocator Allocator
Definition: MIParser.h:50
bool parseNamedRegisterReference(PerFunctionMIParsingState &PFS, unsigned &Reg, StringRef Src, SMDiagnostic &Error)
Definition: MIParser.cpp:2552
MachineFunction & MF
Definition: MIParser.h:51
This owns the files read by a parser, handles include stacks, and handles diagnostic wrangling...
Definition: SourceMgr.h:41
const SlotMapping & IRSlots
Definition: MIParser.h:53
bool parseMachineInstructions(PerFunctionMIParsingState &PFS, StringRef Src, SMDiagnostic &Error)
Parse the machine instructions.
Definition: MIParser.cpp:2535
const Name2RegClassMap & Names2RegClasses
Definition: MIParser.h:54
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:2570
bool Explicit
VReg was explicitly specified in the .mir file.
Definition: MIParser.h:37
unsigned VReg
Definition: MIParser.h:42
DenseMap< unsigned, MachineBasicBlock * > MBBSlots
Definition: MIParser.h:57
Lightweight error class with error context and mandatory checking.
Definition: Error.h:156
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:49
const RegisterBank * RegBank
Definition: MIParser.h:40
bool parseRegisterReference(PerFunctionMIParsingState &PFS, unsigned &Reg, StringRef Src, SMDiagnostic &Error)
Definition: MIParser.cpp:2546
Instances of this class encapsulate one diagnostic report, allowing printing to a raw_ostream as a ca...
Definition: SourceMgr.h:232
PerFunctionMIParsingState(MachineFunction &MF, SourceMgr &SM, const SlotMapping &IRSlots, const Name2RegClassMap &Names2RegClasses, const Name2RegBankMap &Names2RegBanks)
Definition: MIParser.cpp:82