LLVM  8.0.1
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 
64 
66  const SlotMapping &IRSlots,
67  const Name2RegClassMap &Names2RegClasses,
68  const Name2RegBankMap &Names2RegBanks);
69 
70  VRegInfo &getVRegInfo(unsigned Num);
71  VRegInfo &getVRegInfoNamed(StringRef RegName);
72 };
73 
74 /// Parse the machine basic block definitions, and skip the machine
75 /// instructions.
76 ///
77 /// This function runs the first parsing pass on the machine function's body.
78 /// It parses only the machine basic block definitions and creates the machine
79 /// basic blocks in the given machine function.
80 ///
81 /// The machine instructions aren't parsed during the first pass because all
82 /// the machine basic blocks aren't defined yet - this makes it impossible to
83 /// resolve the machine basic block references.
84 ///
85 /// Return true if an error occurred.
88 
89 /// Parse the machine instructions.
90 ///
91 /// This function runs the second parsing pass on the machine function's body.
92 /// It skips the machine basic block definitions and parses only the machine
93 /// instructions and basic block attributes like liveins and successors.
94 ///
95 /// The second parsing pass assumes that the first parsing pass already ran
96 /// on the given source string.
97 ///
98 /// Return true if an error occurred.
101 
103  MachineBasicBlock *&MBB, StringRef Src,
105 
107  unsigned &Reg, StringRef Src,
109 
112 
114  VRegInfo *&Info, StringRef Src,
116 
119 
122 
123 } // end namespace llvm
124 
125 #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:2961
DenseMap< unsigned, unsigned > JumpTableSlots
Definition: MIParser.h:63
DenseMap< unsigned, unsigned > ConstantPoolSlots
Definition: MIParser.h:62
This class represents lattice values for constants.
Definition: AllocatorList.h:24
unsigned Reg
DenseMap< unsigned, int > StackObjectSlots
Definition: MIParser.h:61
Metadata node.
Definition: Metadata.h:864
DenseMap< unsigned, VRegInfo * > VRegInfos
Definition: MIParser.h:58
bool parseMBBReference(PerFunctionMIParsingState &PFS, MachineBasicBlock *&MBB, StringRef Src, SMDiagnostic &Error)
Definition: MIParser.cpp:2972
const TargetRegisterClass * RC
Definition: MIParser.h:39
This file defines the MallocAllocator and BumpPtrAllocator interfaces.
union llvm::VRegInfo::@347 D
const Name2RegBankMap & Names2RegBanks
Definition: MIParser.h:55
DenseMap< unsigned, int > FixedStackObjectSlots
Definition: MIParser.h:60
unsigned PreferredReg
Definition: MIParser.h:43
bool parseVirtualRegisterReference(PerFunctionMIParsingState &PFS, VRegInfo *&Info, StringRef Src, SMDiagnostic &Error)
Definition: MIParser.cpp:2990
Analysis containing CSE Info
Definition: CSEInfo.cpp:21
bool parseStackObjectReference(PerFunctionMIParsingState &PFS, int &FI, StringRef Src, SMDiagnostic &Error)
Definition: MIParser.cpp:2996
Allocate memory in an ever growing pool, as if by bump-pointer.
Definition: Allocator.h:141
StringMap< VRegInfo * > VRegInfosNamed
Definition: MIParser.h:59
BumpPtrAllocator Allocator
Definition: MIParser.h:50
bool parseNamedRegisterReference(PerFunctionMIParsingState &PFS, unsigned &Reg, StringRef Src, SMDiagnostic &Error)
Definition: MIParser.cpp:2984
MachineFunction & MF
Definition: MIParser.h:51
This owns the files read by a parser, handles include stacks, and handles diagnostic wrangling...
Definition: SourceMgr.h:42
const SlotMapping & IRSlots
Definition: MIParser.h:53
bool parseMachineInstructions(PerFunctionMIParsingState &PFS, StringRef Src, SMDiagnostic &Error)
Parse the machine instructions.
Definition: MIParser.cpp:2967
const Name2RegClassMap & Names2RegClasses
Definition: MIParser.h:54
enum llvm::VRegInfo::uint8_t Kind
This class implements the register bank concept.
Definition: RegisterBank.h:29
StringMap - This is an unconventional map that is specialized for handling keys that are "strings"...
Definition: StringMap.h:220
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:3002
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:158
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:2978
Instances of this class encapsulate one diagnostic report, allowing printing to a raw_ostream as a ca...
Definition: SourceMgr.h:260