2015-06-23 01:02:30 +08: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-27 00:46:11 +08:00
|
|
|
#include "llvm/ADT/DenseMap.h"
|
2016-06-09 07:27:46 +08:00
|
|
|
#include "llvm/ADT/SmallSet.h"
|
2015-06-23 01:02:30 +08:00
|
|
|
|
|
|
|
namespace llvm {
|
|
|
|
|
2016-04-18 17:17:29 +08:00
|
|
|
class StringRef;
|
2015-07-28 06:42:41 +08:00
|
|
|
class BasicBlock;
|
2015-06-27 00:46:11 +08:00
|
|
|
class MachineBasicBlock;
|
2015-06-23 01:02:30 +08:00
|
|
|
class MachineFunction;
|
2016-07-14 06:23:23 +08:00
|
|
|
class MachineInstr;
|
|
|
|
class MachineRegisterInfo;
|
2015-08-19 08:13:25 +08:00
|
|
|
class MDNode;
|
2015-06-27 06:56:48 +08:00
|
|
|
struct SlotMapping;
|
2015-06-23 01:02:30 +08:00
|
|
|
class SMDiagnostic;
|
|
|
|
class SourceMgr;
|
|
|
|
|
2015-07-08 01:46:43 +08:00
|
|
|
struct PerFunctionMIParsingState {
|
2016-07-14 06:23:23 +08:00
|
|
|
MachineFunction &MF;
|
2016-07-14 07:27:50 +08:00
|
|
|
SourceMgr *SM;
|
|
|
|
const SlotMapping &IRSlots;
|
2016-07-14 06:23:23 +08:00
|
|
|
|
2015-07-08 01:46:43 +08:00
|
|
|
DenseMap<unsigned, MachineBasicBlock *> MBBSlots;
|
2015-07-11 06:51:20 +08:00
|
|
|
DenseMap<unsigned, unsigned> VirtualRegisterSlots;
|
2015-07-17 07:37:45 +08:00
|
|
|
DenseMap<unsigned, int> FixedStackObjectSlots;
|
|
|
|
DenseMap<unsigned, int> StackObjectSlots;
|
2015-07-21 04:51:18 +08:00
|
|
|
DenseMap<unsigned, unsigned> ConstantPoolSlots;
|
2015-07-16 07:38:35 +08:00
|
|
|
DenseMap<unsigned, unsigned> JumpTableSlots;
|
2016-06-09 07:27:46 +08:00
|
|
|
/// Hold the generic virtual registers.
|
|
|
|
SmallSet<unsigned, 8> GenericVRegs;
|
2016-07-14 06:23:23 +08:00
|
|
|
|
2016-07-14 07:27:50 +08:00
|
|
|
PerFunctionMIParsingState(MachineFunction &MF, SourceMgr &SM,
|
|
|
|
const SlotMapping &IRSlots);
|
2015-07-08 01:46:43 +08:00
|
|
|
};
|
|
|
|
|
2015-08-14 07:10:16 +08: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.
|
2016-07-14 06:23:23 +08:00
|
|
|
bool parseMachineBasicBlockDefinitions(PerFunctionMIParsingState &PFS,
|
2016-07-14 07:27:50 +08:00
|
|
|
StringRef Src, SMDiagnostic &Error);
|
2015-08-14 07:10:16 +08:00
|
|
|
|
|
|
|
/// 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.
|
2016-07-14 06:23:23 +08:00
|
|
|
bool parseMachineInstructions(const PerFunctionMIParsingState &PFS,
|
2016-07-14 07:27:50 +08:00
|
|
|
StringRef Src, SMDiagnostic &Error);
|
2016-07-14 06:23:23 +08:00
|
|
|
|
|
|
|
bool parseMBBReference(const PerFunctionMIParsingState &PFS,
|
2016-07-14 07:27:50 +08:00
|
|
|
MachineBasicBlock *&MBB, StringRef Src,
|
2016-07-14 06:23:23 +08:00
|
|
|
SMDiagnostic &Error);
|
|
|
|
|
|
|
|
bool parseNamedRegisterReference(const PerFunctionMIParsingState &PFS,
|
2016-07-14 07:27:50 +08:00
|
|
|
unsigned &Reg, StringRef Src,
|
2015-07-15 05:24:41 +08:00
|
|
|
SMDiagnostic &Error);
|
|
|
|
|
2016-07-14 06:23:23 +08:00
|
|
|
bool parseVirtualRegisterReference(const PerFunctionMIParsingState &PFS,
|
2016-07-14 07:27:50 +08:00
|
|
|
unsigned &Reg, StringRef Src,
|
2015-07-28 01:42:45 +08:00
|
|
|
SMDiagnostic &Error);
|
|
|
|
|
2016-07-14 06:23:23 +08:00
|
|
|
bool parseStackObjectReference(const PerFunctionMIParsingState &PFS,
|
2016-07-14 07:27:50 +08:00
|
|
|
int &FI, StringRef Src, SMDiagnostic &Error);
|
2015-08-19 06:26:26 +08:00
|
|
|
|
2016-07-14 06:23:23 +08:00
|
|
|
bool parseMDNode(const PerFunctionMIParsingState &PFS, MDNode *&Node,
|
2016-07-14 07:27:50 +08:00
|
|
|
StringRef Src, SMDiagnostic &Error);
|
2015-08-19 08:13:25 +08:00
|
|
|
|
2015-06-23 01:02:30 +08:00
|
|
|
} // end namespace llvm
|
|
|
|
|
|
|
|
#endif
|