mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-07-24 22:24:54 +00:00
MIR Serialization: Serialize the list of machine basic blocks with simple attributes.
This commit implements the initial serialization of machine basic blocks in a machine function. Only the simple, scalar MBB attributes are serialized. The reference to LLVM IR's basic block is preserved when that basic block has a name. Reviewers: Duncan P. N. Exon Smith Differential Revision: http://reviews.llvm.org/D10465 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@240145 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -19,10 +19,12 @@
|
||||
#include "llvm/AsmParser/Parser.h"
|
||||
#include "llvm/CodeGen/MachineFunction.h"
|
||||
#include "llvm/CodeGen/MIRYamlMapping.h"
|
||||
#include "llvm/IR/BasicBlock.h"
|
||||
#include "llvm/IR/DiagnosticInfo.h"
|
||||
#include "llvm/IR/Instructions.h"
|
||||
#include "llvm/IR/LLVMContext.h"
|
||||
#include "llvm/IR/Module.h"
|
||||
#include "llvm/IR/ValueSymbolTable.h"
|
||||
#include "llvm/Support/LineIterator.h"
|
||||
#include "llvm/Support/SMLoc.h"
|
||||
#include "llvm/Support/SourceMgr.h"
|
||||
@@ -74,6 +76,12 @@ public:
|
||||
/// Return true if error occurred.
|
||||
bool initializeMachineFunction(MachineFunction &MF);
|
||||
|
||||
/// Initialize the machine basic block using it's YAML representation.
|
||||
///
|
||||
/// Return true if an error occurred.
|
||||
bool initializeMachineBasicBlock(MachineBasicBlock &MBB,
|
||||
const yaml::MachineBasicBlock &YamlMBB);
|
||||
|
||||
private:
|
||||
/// Return a MIR diagnostic converted from an LLVM assembly diagnostic.
|
||||
SMDiagnostic diagFromLLVMAssemblyDiag(const SMDiagnostic &Error,
|
||||
@@ -198,6 +206,28 @@ bool MIRParserImpl::initializeMachineFunction(MachineFunction &MF) {
|
||||
MF.setAlignment(YamlMF.Alignment);
|
||||
MF.setExposesReturnsTwice(YamlMF.ExposesReturnsTwice);
|
||||
MF.setHasInlineAsm(YamlMF.HasInlineAsm);
|
||||
const auto &F = *MF.getFunction();
|
||||
for (const auto &YamlMBB : YamlMF.BasicBlocks) {
|
||||
const BasicBlock *BB = nullptr;
|
||||
if (!YamlMBB.Name.empty()) {
|
||||
BB = dyn_cast_or_null<BasicBlock>(
|
||||
F.getValueSymbolTable().lookup(YamlMBB.Name));
|
||||
// TODO: Report an error if a basic block isn't found.
|
||||
}
|
||||
auto *MBB = MF.CreateMachineBasicBlock(BB);
|
||||
MF.insert(MF.end(), MBB);
|
||||
if (initializeMachineBasicBlock(*MBB, YamlMBB))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool MIRParserImpl::initializeMachineBasicBlock(
|
||||
MachineBasicBlock &MBB, const yaml::MachineBasicBlock &YamlMBB) {
|
||||
MBB.setAlignment(YamlMBB.Alignment);
|
||||
if (YamlMBB.AddressTaken)
|
||||
MBB.setHasAddressTaken();
|
||||
MBB.setIsLandingPad(YamlMBB.IsLandingPad);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user