summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/MIRParser/MIRParser.cpp
diff options
context:
space:
mode:
authorAlex Lorenz <arphaman@gmail.com>2015-06-22 17:02:30 +0000
committerAlex Lorenz <arphaman@gmail.com>2015-06-22 17:02:30 +0000
commit8e0a1b4857faf0ea9504ec254020dc22cd4f6cc1 (patch)
tree8f7b6b2153ae6936a7a9e32282fda87e95c5a5fe /llvm/lib/CodeGen/MIRParser/MIRParser.cpp
parent7f09a98ab138886454dfdf123a9fe9811ac20fb3 (diff)
downloadbcm5719-llvm-8e0a1b4857faf0ea9504ec254020dc22cd4f6cc1.tar.gz
bcm5719-llvm-8e0a1b4857faf0ea9504ec254020dc22cd4f6cc1.zip
MIR Serialization: Serialize machine instruction names.
This commit implements initial machine instruction serialization. It serializes machine instruction names. The instructions are represented using a YAML sequence of string literals and are a part of machine basic block YAML mapping. This commit introduces a class called 'MIParser' which will be used to parse the machine instructions and operands. Reviewers: Duncan P. N. Exon Smith Differential Revision: http://reviews.llvm.org/D10481 llvm-svn: 240295
Diffstat (limited to 'llvm/lib/CodeGen/MIRParser/MIRParser.cpp')
-rw-r--r--llvm/lib/CodeGen/MIRParser/MIRParser.cpp18
1 files changed, 15 insertions, 3 deletions
diff --git a/llvm/lib/CodeGen/MIRParser/MIRParser.cpp b/llvm/lib/CodeGen/MIRParser/MIRParser.cpp
index 1fef3f6dcb3..1ba7f1f1df2 100644
--- a/llvm/lib/CodeGen/MIRParser/MIRParser.cpp
+++ b/llvm/lib/CodeGen/MIRParser/MIRParser.cpp
@@ -13,6 +13,7 @@
//===----------------------------------------------------------------------===//
#include "llvm/CodeGen/MIRParser/MIRParser.h"
+#include "MIParser.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/StringMap.h"
#include "llvm/ADT/STLExtras.h"
@@ -79,7 +80,7 @@ public:
/// Initialize the machine basic block using it's YAML representation.
///
/// Return true if an error occurred.
- bool initializeMachineBasicBlock(MachineBasicBlock &MBB,
+ bool initializeMachineBasicBlock(MachineFunction &MF, MachineBasicBlock &MBB,
const yaml::MachineBasicBlock &YamlMBB);
private:
@@ -218,18 +219,29 @@ bool MIRParserImpl::initializeMachineFunction(MachineFunction &MF) {
}
auto *MBB = MF.CreateMachineBasicBlock(BB);
MF.insert(MF.end(), MBB);
- if (initializeMachineBasicBlock(*MBB, YamlMBB))
+ if (initializeMachineBasicBlock(MF, *MBB, YamlMBB))
return true;
}
return false;
}
bool MIRParserImpl::initializeMachineBasicBlock(
- MachineBasicBlock &MBB, const yaml::MachineBasicBlock &YamlMBB) {
+ MachineFunction &MF, MachineBasicBlock &MBB,
+ const yaml::MachineBasicBlock &YamlMBB) {
MBB.setAlignment(YamlMBB.Alignment);
if (YamlMBB.AddressTaken)
MBB.setHasAddressTaken();
MBB.setIsLandingPad(YamlMBB.IsLandingPad);
+ // Parse the instructions.
+ for (const auto &MISource : YamlMBB.Instructions) {
+ SMDiagnostic Error;
+ if (auto *MI = parseMachineInstr(SM, MF, MISource, Error)) {
+ MBB.insert(MBB.end(), MI);
+ continue;
+ }
+ reportDiagnostic(Error);
+ return true;
+ }
return false;
}
OpenPOWER on IntegriCloud