LLVM  9.0.0svn
MIParser.h
Go to the documentation of this file.
1 //===- MIParser.h - Machine Instructions Parser -----------------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file declares the function that parses the machine instructions.
10 //
11 //===----------------------------------------------------------------------===//
12 
13 #ifndef LLVM_LIB_CODEGEN_MIRPARSER_MIPARSER_H
14 #define LLVM_LIB_CODEGEN_MIRPARSER_MIPARSER_H
15 
16 #include "llvm/ADT/DenseMap.h"
17 #include "llvm/ADT/StringMap.h"
18 #include "llvm/Support/Allocator.h"
19 
20 namespace llvm {
21 
22 class MachineBasicBlock;
23 class MachineFunction;
24 class MDNode;
25 class RegisterBank;
26 struct SlotMapping;
27 class SMDiagnostic;
28 class SourceMgr;
29 class StringRef;
30 class TargetRegisterClass;
31 
32 struct VRegInfo {
33  enum uint8_t {
35  } Kind = UNKNOWN;
36  bool Explicit = false; ///< VReg was explicitly specified in the .mir file.
37  union {
40  } D;
41  unsigned VReg;
42  unsigned PreferredReg = 0;
43 };
44 
47 
55 
63 
65  const SlotMapping &IRSlots,
66  const Name2RegClassMap &Names2RegClasses,
67  const Name2RegBankMap &Names2RegBanks);
68 
69  VRegInfo &getVRegInfo(unsigned Num);
70  VRegInfo &getVRegInfoNamed(StringRef RegName);
71 };
72 
73 /// Parse the machine basic block definitions, and skip the machine
74 /// instructions.
75 ///
76 /// This function runs the first parsing pass on the machine function's body.
77 /// It parses only the machine basic block definitions and creates the machine
78 /// basic blocks in the given machine function.
79 ///
80 /// The machine instructions aren't parsed during the first pass because all
81 /// the machine basic blocks aren't defined yet - this makes it impossible to
82 /// resolve the machine basic block references.
83 ///
84 /// Return true if an error occurred.
87 
88 /// Parse the machine instructions.
89 ///
90 /// This function runs the second parsing pass on the machine function's body.
91 /// It skips the machine basic block definitions and parses only the machine
92 /// instructions and basic block attributes like liveins and successors.
93 ///
94 /// The second parsing pass assumes that the first parsing pass already ran
95 /// on the given source string.
96 ///
97 /// Return true if an error occurred.
100 
102  MachineBasicBlock *&MBB, StringRef Src,
104 
106  unsigned &Reg, StringRef Src,
108 
111 
113  VRegInfo *&Info, StringRef Src,
115 
118 
121 
122 } // end namespace llvm
123 
124 #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:2993
DenseMap< unsigned, unsigned > JumpTableSlots
Definition: MIParser.h:62
DenseMap< unsigned, unsigned > ConstantPoolSlots
Definition: MIParser.h:61
This class represents lattice values for constants.
Definition: AllocatorList.h:23
unsigned Reg
DenseMap< unsigned, int > StackObjectSlots
Definition: MIParser.h:60
Metadata node.
Definition: Metadata.h:863
DenseMap< unsigned, VRegInfo * > VRegInfos
Definition: MIParser.h:57
bool parseMBBReference(PerFunctionMIParsingState &PFS, MachineBasicBlock *&MBB, StringRef Src, SMDiagnostic &Error)
Definition: MIParser.cpp:3004
const TargetRegisterClass * RC
Definition: MIParser.h:38
This file defines the MallocAllocator and BumpPtrAllocator interfaces.
const Name2RegBankMap & Names2RegBanks
Definition: MIParser.h:54
DenseMap< unsigned, int > FixedStackObjectSlots
Definition: MIParser.h:59
unsigned PreferredReg
Definition: MIParser.h:42
bool parseVirtualRegisterReference(PerFunctionMIParsingState &PFS, VRegInfo *&Info, StringRef Src, SMDiagnostic &Error)
Definition: MIParser.cpp:3022
Analysis containing CSE Info
Definition: CSEInfo.cpp:20
bool parseStackObjectReference(PerFunctionMIParsingState &PFS, int &FI, StringRef Src, SMDiagnostic &Error)
Definition: MIParser.cpp:3028
union llvm::VRegInfo::@346 D
Allocate memory in an ever growing pool, as if by bump-pointer.
Definition: Allocator.h:140
StringMap< VRegInfo * > VRegInfosNamed
Definition: MIParser.h:58
BumpPtrAllocator Allocator
Definition: MIParser.h:49
bool parseNamedRegisterReference(PerFunctionMIParsingState &PFS, unsigned &Reg, StringRef Src, SMDiagnostic &Error)
Definition: MIParser.cpp:3016
MachineFunction & MF
Definition: MIParser.h:50
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:52
bool parseMachineInstructions(PerFunctionMIParsingState &PFS, StringRef Src, SMDiagnostic &Error)
Parse the machine instructions.
Definition: MIParser.cpp:2999
const Name2RegClassMap & Names2RegClasses
Definition: MIParser.h:53
enum llvm::VRegInfo::uint8_t Kind
This class implements the register bank concept.
Definition: RegisterBank.h:28
StringMap - This is an unconventional map that is specialized for handling keys that are "strings"...
Definition: StringMap.h:219
This struct contains the mappings from the slot numbers to unnamed metadata nodes, global values and types.
Definition: SlotMapping.h:32
bool parseMDNode(PerFunctionMIParsingState &PFS, MDNode *&Node, StringRef Src, SMDiagnostic &Error)
Definition: MIParser.cpp:3034
bool Explicit
VReg was explicitly specified in the .mir file.
Definition: MIParser.h:36
unsigned VReg
Definition: MIParser.h:41
DenseMap< unsigned, MachineBasicBlock * > MBBSlots
Definition: MIParser.h:56
Lightweight error class with error context and mandatory checking.
Definition: Error.h:157
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:48
const RegisterBank * RegBank
Definition: MIParser.h:39
bool parseRegisterReference(PerFunctionMIParsingState &PFS, unsigned &Reg, StringRef Src, SMDiagnostic &Error)
Definition: MIParser.cpp:3010
Instances of this class encapsulate one diagnostic report, allowing printing to a raw_ostream as a ca...
Definition: SourceMgr.h:259