1 //===- MIParser.h - Machine Instructions Parser ---------------------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file declares the function that parses the machine instructions.
12 //===----------------------------------------------------------------------===//
14 #ifndef LLVM_LIB_CODEGEN_MIRPARSER_MIPARSER_H
15 #define LLVM_LIB_CODEGEN_MIRPARSER_MIPARSER_H
17 #include "llvm/ADT/DenseMap.h"
18 #include "llvm/ADT/StringRef.h"
23 class MachineBasicBlock;
25 class MachineFunction;
31 struct PerFunctionMIParsingState {
32 DenseMap<unsigned, MachineBasicBlock *> MBBSlots;
33 DenseMap<unsigned, unsigned> VirtualRegisterSlots;
34 DenseMap<unsigned, int> FixedStackObjectSlots;
35 DenseMap<unsigned, int> StackObjectSlots;
36 DenseMap<unsigned, unsigned> ConstantPoolSlots;
37 DenseMap<unsigned, unsigned> JumpTableSlots;
40 /// Parse the machine basic block definitions, and skip the machine
43 /// This function runs the first parsing pass on the machine function's body.
44 /// It parses only the machine basic block definitions and creates the machine
45 /// basic blocks in the given machine function.
47 /// The machine instructions aren't parsed during the first pass because all
48 /// the machine basic blocks aren't defined yet - this makes it impossible to
49 /// resolve the machine basic block references.
51 /// Return true if an error occurred.
52 bool parseMachineBasicBlockDefinitions(MachineFunction &MF, StringRef Src,
53 PerFunctionMIParsingState &PFS,
54 const SlotMapping &IRSlots,
57 /// Parse the machine instructions.
59 /// This function runs the second parsing pass on the machine function's body.
60 /// It skips the machine basic block definitions and parses only the machine
61 /// instructions and basic block attributes like liveins and successors.
63 /// The second parsing pass assumes that the first parsing pass already ran
64 /// on the given source string.
66 /// Return true if an error occurred.
67 bool parseMachineInstructions(MachineFunction &MF, StringRef Src,
68 const PerFunctionMIParsingState &PFS,
69 const SlotMapping &IRSlots, SMDiagnostic &Error);
71 bool parseMBBReference(MachineBasicBlock *&MBB, SourceMgr &SM,
72 MachineFunction &MF, StringRef Src,
73 const PerFunctionMIParsingState &PFS,
74 const SlotMapping &IRSlots, SMDiagnostic &Error);
76 bool parseNamedRegisterReference(unsigned &Reg, SourceMgr &SM,
77 MachineFunction &MF, StringRef Src,
78 const PerFunctionMIParsingState &PFS,
79 const SlotMapping &IRSlots,
82 bool parseVirtualRegisterReference(unsigned &Reg, SourceMgr &SM,
83 MachineFunction &MF, StringRef Src,
84 const PerFunctionMIParsingState &PFS,
85 const SlotMapping &IRSlots,
88 bool parseStackObjectReference(int &FI, SourceMgr &SM, MachineFunction &MF,
90 const PerFunctionMIParsingState &PFS,
91 const SlotMapping &IRSlots, SMDiagnostic &Error);
93 bool parseMDNode(MDNode *&Node, SourceMgr &SM, MachineFunction &MF,
94 StringRef Src, const PerFunctionMIParsingState &PFS,
95 const SlotMapping &IRSlots, SMDiagnostic &Error);
97 } // end namespace llvm