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;
30 struct PerFunctionMIParsingState {
31 DenseMap<unsigned, MachineBasicBlock *> MBBSlots;
32 DenseMap<unsigned, unsigned> VirtualRegisterSlots;
33 DenseMap<unsigned, int> FixedStackObjectSlots;
34 DenseMap<unsigned, int> StackObjectSlots;
35 DenseMap<unsigned, unsigned> ConstantPoolSlots;
36 DenseMap<unsigned, unsigned> JumpTableSlots;
39 /// Parse the machine basic block definitions, and skip the machine
42 /// This function runs the first parsing pass on the machine function's body.
43 /// It parses only the machine basic block definitions and creates the machine
44 /// basic blocks in the given machine function.
46 /// The machine instructions aren't parsed during the first pass because all
47 /// the machine basic blocks aren't defined yet - this makes it impossible to
48 /// resolve the machine basic block references.
50 /// Return true if an error occurred.
51 bool parseMachineBasicBlockDefinitions(MachineFunction &MF, StringRef Src,
52 PerFunctionMIParsingState &PFS,
53 const SlotMapping &IRSlots,
56 /// Parse the machine instructions.
58 /// This function runs the second parsing pass on the machine function's body.
59 /// It skips the machine basic block definitions and parses only the machine
60 /// instructions and basic block attributes like liveins and successors.
62 /// The second parsing pass assumes that the first parsing pass already ran
63 /// on the given source string.
65 /// Return true if an error occurred.
66 bool parseMachineInstructions(MachineFunction &MF, StringRef Src,
67 const PerFunctionMIParsingState &PFS,
68 const SlotMapping &IRSlots, SMDiagnostic &Error);
70 bool parseMBBReference(MachineBasicBlock *&MBB, SourceMgr &SM,
71 MachineFunction &MF, StringRef Src,
72 const PerFunctionMIParsingState &PFS,
73 const SlotMapping &IRSlots, SMDiagnostic &Error);
75 bool parseNamedRegisterReference(unsigned &Reg, SourceMgr &SM,
76 MachineFunction &MF, StringRef Src,
77 const PerFunctionMIParsingState &PFS,
78 const SlotMapping &IRSlots,
81 bool parseVirtualRegisterReference(unsigned &Reg, SourceMgr &SM,
82 MachineFunction &MF, StringRef Src,
83 const PerFunctionMIParsingState &PFS,
84 const SlotMapping &IRSlots,
87 } // end namespace llvm