2015-06-22 19:02:30 +02:00
|
|
|
//===- MIParser.h - Machine Instructions Parser ---------------------------===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// This file declares the function that parses the machine instructions.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#ifndef LLVM_LIB_CODEGEN_MIRPARSER_MIPARSER_H
|
|
|
|
#define LLVM_LIB_CODEGEN_MIRPARSER_MIPARSER_H
|
|
|
|
|
2015-06-26 18:46:11 +02:00
|
|
|
#include "llvm/ADT/DenseMap.h"
|
2015-06-22 19:02:30 +02:00
|
|
|
|
|
|
|
namespace llvm {
|
|
|
|
|
2016-04-18 11:17:29 +02:00
|
|
|
class StringRef;
|
2015-07-28 00:42:41 +02:00
|
|
|
class BasicBlock;
|
2015-06-26 18:46:11 +02:00
|
|
|
class MachineBasicBlock;
|
2015-06-22 19:02:30 +02:00
|
|
|
class MachineInstr;
|
|
|
|
class MachineFunction;
|
2015-08-19 02:13:25 +02:00
|
|
|
class MDNode;
|
2015-06-27 00:56:48 +02:00
|
|
|
struct SlotMapping;
|
2015-06-22 19:02:30 +02:00
|
|
|
class SMDiagnostic;
|
|
|
|
class SourceMgr;
|
|
|
|
|
2015-07-07 19:46:43 +02:00
|
|
|
struct PerFunctionMIParsingState {
|
|
|
|
DenseMap<unsigned, MachineBasicBlock *> MBBSlots;
|
2015-07-11 00:51:20 +02:00
|
|
|
DenseMap<unsigned, unsigned> VirtualRegisterSlots;
|
2015-07-17 01:37:45 +02:00
|
|
|
DenseMap<unsigned, int> FixedStackObjectSlots;
|
|
|
|
DenseMap<unsigned, int> StackObjectSlots;
|
2015-07-20 22:51:18 +02:00
|
|
|
DenseMap<unsigned, unsigned> ConstantPoolSlots;
|
2015-07-16 01:38:35 +02:00
|
|
|
DenseMap<unsigned, unsigned> JumpTableSlots;
|
2015-07-07 19:46:43 +02:00
|
|
|
};
|
|
|
|
|
2015-08-14 01:10:16 +02:00
|
|
|
/// Parse the machine basic block definitions, and skip the machine
|
|
|
|
/// instructions.
|
|
|
|
///
|
|
|
|
/// This function runs the first parsing pass on the machine function's body.
|
|
|
|
/// It parses only the machine basic block definitions and creates the machine
|
|
|
|
/// basic blocks in the given machine function.
|
|
|
|
///
|
|
|
|
/// The machine instructions aren't parsed during the first pass because all
|
|
|
|
/// the machine basic blocks aren't defined yet - this makes it impossible to
|
|
|
|
/// resolve the machine basic block references.
|
|
|
|
///
|
|
|
|
/// Return true if an error occurred.
|
|
|
|
bool parseMachineBasicBlockDefinitions(MachineFunction &MF, StringRef Src,
|
|
|
|
PerFunctionMIParsingState &PFS,
|
|
|
|
const SlotMapping &IRSlots,
|
|
|
|
SMDiagnostic &Error);
|
|
|
|
|
|
|
|
/// Parse the machine instructions.
|
|
|
|
///
|
|
|
|
/// This function runs the second parsing pass on the machine function's body.
|
|
|
|
/// It skips the machine basic block definitions and parses only the machine
|
|
|
|
/// instructions and basic block attributes like liveins and successors.
|
|
|
|
///
|
|
|
|
/// The second parsing pass assumes that the first parsing pass already ran
|
|
|
|
/// on the given source string.
|
|
|
|
///
|
|
|
|
/// Return true if an error occurred.
|
|
|
|
bool parseMachineInstructions(MachineFunction &MF, StringRef Src,
|
|
|
|
const PerFunctionMIParsingState &PFS,
|
|
|
|
const SlotMapping &IRSlots, SMDiagnostic &Error);
|
2015-06-22 19:02:30 +02:00
|
|
|
|
2015-06-30 20:16:42 +02:00
|
|
|
bool parseMBBReference(MachineBasicBlock *&MBB, SourceMgr &SM,
|
|
|
|
MachineFunction &MF, StringRef Src,
|
2015-07-07 19:46:43 +02:00
|
|
|
const PerFunctionMIParsingState &PFS,
|
2015-06-30 20:16:42 +02:00
|
|
|
const SlotMapping &IRSlots, SMDiagnostic &Error);
|
|
|
|
|
2015-07-14 23:24:41 +02:00
|
|
|
bool parseNamedRegisterReference(unsigned &Reg, SourceMgr &SM,
|
|
|
|
MachineFunction &MF, StringRef Src,
|
|
|
|
const PerFunctionMIParsingState &PFS,
|
|
|
|
const SlotMapping &IRSlots,
|
|
|
|
SMDiagnostic &Error);
|
|
|
|
|
2015-07-27 19:42:45 +02:00
|
|
|
bool parseVirtualRegisterReference(unsigned &Reg, SourceMgr &SM,
|
|
|
|
MachineFunction &MF, StringRef Src,
|
|
|
|
const PerFunctionMIParsingState &PFS,
|
|
|
|
const SlotMapping &IRSlots,
|
|
|
|
SMDiagnostic &Error);
|
|
|
|
|
2015-08-19 00:26:26 +02:00
|
|
|
bool parseStackObjectReference(int &FI, SourceMgr &SM, MachineFunction &MF,
|
|
|
|
StringRef Src,
|
|
|
|
const PerFunctionMIParsingState &PFS,
|
|
|
|
const SlotMapping &IRSlots, SMDiagnostic &Error);
|
|
|
|
|
2015-08-19 02:13:25 +02:00
|
|
|
bool parseMDNode(MDNode *&Node, SourceMgr &SM, MachineFunction &MF,
|
|
|
|
StringRef Src, const PerFunctionMIParsingState &PFS,
|
|
|
|
const SlotMapping &IRSlots, SMDiagnostic &Error);
|
|
|
|
|
2015-06-22 19:02:30 +02:00
|
|
|
} // end namespace llvm
|
|
|
|
|
|
|
|
#endif
|