forked from OSchip/llvm-project
MIR Serialization: Serialize the memory operand's range metadata node.
llvm-svn: 245247
This commit is contained in:
parent
03e940d1f8
commit
eb62568625
|
@ -447,6 +447,7 @@ static MIToken::TokenKind getMetadataKeywordKind(StringRef Identifier) {
|
|||
.Case("!tbaa", MIToken::md_tbaa)
|
||||
.Case("!alias.scope", MIToken::md_alias_scope)
|
||||
.Case("!noalias", MIToken::md_noalias)
|
||||
.Case("!range", MIToken::md_range)
|
||||
.Default(MIToken::Error);
|
||||
}
|
||||
|
||||
|
|
|
@ -89,6 +89,7 @@ struct MIToken {
|
|||
md_tbaa,
|
||||
md_alias_scope,
|
||||
md_noalias,
|
||||
md_range,
|
||||
|
||||
// Identifier tokens
|
||||
Identifier,
|
||||
|
|
|
@ -1527,6 +1527,7 @@ bool MIParser::parseMachineMemoryOperand(MachineMemOperand *&Dest) {
|
|||
return true;
|
||||
unsigned BaseAlignment = Size;
|
||||
AAMDNodes AAInfo;
|
||||
MDNode *Range = nullptr;
|
||||
while (consumeIfPresent(MIToken::comma)) {
|
||||
switch (Token.kind()) {
|
||||
case MIToken::kw_align:
|
||||
|
@ -1548,16 +1549,21 @@ bool MIParser::parseMachineMemoryOperand(MachineMemOperand *&Dest) {
|
|||
if (parseMDNode(AAInfo.NoAlias))
|
||||
return true;
|
||||
break;
|
||||
// TODO: Parse the ranges metadata.
|
||||
case MIToken::md_range:
|
||||
lex();
|
||||
if (parseMDNode(Range))
|
||||
return true;
|
||||
break;
|
||||
// TODO: Report an error on duplicate metadata nodes.
|
||||
default:
|
||||
return error(
|
||||
"expected 'align' or '!tbaa' or '!alias.scope' or '!noalias'");
|
||||
return error("expected 'align' or '!tbaa' or '!alias.scope' or "
|
||||
"'!noalias' or '!range'");
|
||||
}
|
||||
}
|
||||
if (expectAndConsume(MIToken::rparen))
|
||||
return true;
|
||||
Dest = MF.getMachineMemOperand(Ptr, Flags, Size, BaseAlignment, AAInfo);
|
||||
Dest =
|
||||
MF.getMachineMemOperand(Ptr, Flags, Size, BaseAlignment, AAInfo, Range);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -790,7 +790,10 @@ void MIPrinter::print(const MachineMemOperand &Op) {
|
|||
OS << ", !noalias ";
|
||||
AAInfo.NoAlias->printAsOperand(OS, MST);
|
||||
}
|
||||
// TODO: Print the ranges metadata.
|
||||
if (Op.getRanges()) {
|
||||
OS << ", !range ";
|
||||
Op.getRanges()->printAsOperand(OS, MST);
|
||||
}
|
||||
OS << ')';
|
||||
}
|
||||
|
||||
|
|
|
@ -148,6 +148,15 @@
|
|||
!9 = distinct !{!9, !10, !"some scope"}
|
||||
!10 = distinct !{!10, !"some domain"}
|
||||
|
||||
define zeroext i1 @range_metadata(i8* %x) {
|
||||
entry:
|
||||
%0 = load i8, i8* %x, align 1, !range !11
|
||||
%tobool = trunc i8 %0 to i1
|
||||
ret i1 %tobool
|
||||
}
|
||||
|
||||
!11 = !{i8 0, i8 2}
|
||||
|
||||
...
|
||||
---
|
||||
name: test
|
||||
|
@ -406,3 +415,16 @@ body: |
|
|||
MOVSSmr killed %rdi, 1, _, 28, _, killed %xmm0 :: (store 4 into %ir.arrayidx)
|
||||
RETQ
|
||||
...
|
||||
---
|
||||
name: range_metadata
|
||||
tracksRegLiveness: true
|
||||
liveins:
|
||||
- { reg: '%rdi' }
|
||||
body: |
|
||||
bb.0.entry:
|
||||
liveins: %rdi
|
||||
; CHECK-LABEL: name: range_metadata
|
||||
; CHECK: %al = MOV8rm killed %rdi, 1, _, 0, _ :: (load 1 from %ir.x, !range !11)
|
||||
%al = MOV8rm killed %rdi, 1, _, 0, _ :: (load 1 from %ir.x, !range !11)
|
||||
RETQ %al
|
||||
...
|
||||
|
|
Loading…
Reference in New Issue