[PATCH] D36092: [MIR] Print target specific constant pools
Diana Picus via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Aug 1 04:31:12 PDT 2017
rovka updated this revision to Diff 109081.
rovka edited the summary of this revision.
rovka added a comment.
Thanks for the detailed response!
I added another field (isTargetSpecific) and made the parser produce a more meaningful error message when encountering one of those.
I'll look a bit more into the parser, but I'm not making any promises yet :)
https://reviews.llvm.org/D36092
Files:
include/llvm/CodeGen/MIRYamlMapping.h
lib/CodeGen/MIRParser/MIRParser.cpp
lib/CodeGen/MIRPrinter.cpp
Index: lib/CodeGen/MIRPrinter.cpp
===================================================================
--- lib/CodeGen/MIRPrinter.cpp
+++ lib/CodeGen/MIRPrinter.cpp
@@ -458,17 +458,20 @@
const MachineConstantPool &ConstantPool) {
unsigned ID = 0;
for (const MachineConstantPoolEntry &Constant : ConstantPool.getConstants()) {
- // TODO: Serialize target specific constant pool entries.
- if (Constant.isMachineConstantPoolEntry())
- llvm_unreachable("Can't print target specific constant pool entries yet");
-
- yaml::MachineConstantPoolValue YamlConstant;
std::string Str;
raw_string_ostream StrOS(Str);
- Constant.Val.ConstVal->printAsOperand(StrOS);
+ if (Constant.isMachineConstantPoolEntry()) {
+ Constant.Val.MachineCPVal->print(StrOS);
+ } else {
+ Constant.Val.ConstVal->printAsOperand(StrOS);
+ }
+
+ yaml::MachineConstantPoolValue YamlConstant;
YamlConstant.ID = ID++;
YamlConstant.Value = StrOS.str();
YamlConstant.Alignment = Constant.getAlignment();
+ YamlConstant.IsTargetSpecific = Constant.isMachineConstantPoolEntry();
+
MF.Constants.push_back(YamlConstant);
}
}
Index: lib/CodeGen/MIRParser/MIRParser.cpp
===================================================================
--- lib/CodeGen/MIRParser/MIRParser.cpp
+++ lib/CodeGen/MIRParser/MIRParser.cpp
@@ -719,6 +719,10 @@
const auto &M = *MF.getFunction()->getParent();
SMDiagnostic Error;
for (const auto &YamlConstant : YamlMF.Constants) {
+ if (YamlConstant.IsTargetSpecific)
+ // FIXME: Support target-specific constant pools
+ return error(YamlConstant.Value.SourceRange.Start,
+ "Can't parse target-specific constant pool entries yet");
const Constant *Value = dyn_cast_or_null<Constant>(
parseConstantValue(YamlConstant.Value.Value, Error, M));
if (!Value)
Index: include/llvm/CodeGen/MIRYamlMapping.h
===================================================================
--- include/llvm/CodeGen/MIRYamlMapping.h
+++ include/llvm/CodeGen/MIRYamlMapping.h
@@ -310,6 +310,7 @@
UnsignedValue ID;
StringValue Value;
unsigned Alignment = 0;
+ bool IsTargetSpecific = false;
bool operator==(const MachineConstantPoolValue &Other) const {
return ID == Other.ID && Value == Other.Value &&
Alignment == Other.Alignment;
@@ -321,6 +322,7 @@
YamlIO.mapRequired("id", Constant.ID);
YamlIO.mapOptional("value", Constant.Value, StringValue());
YamlIO.mapOptional("alignment", Constant.Alignment, (unsigned)0);
+ YamlIO.mapOptional("isTargetSpecific", Constant.IsTargetSpecific);
}
};
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D36092.109081.patch
Type: text/x-patch
Size: 2666 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170801/3456323f/attachment.bin>
More information about the llvm-commits
mailing list