mirror of
https://github.com/RPCS3/llvm.git
synced 2024-12-04 01:42:09 +00:00
MCStreamer: Test printing values.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@74076 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
9311ef6a91
commit
f5e75a1fa9
@ -121,7 +121,7 @@ void MCAsmStreamer::EmitValue(const MCValue &Value, unsigned Size) {
|
||||
default:
|
||||
assert(0 && "Invalid size for machine code value!");
|
||||
case 1: OS << ".byte"; break;
|
||||
case 2: OS << ".hword"; break;
|
||||
case 2: OS << ".short"; break;
|
||||
case 4: OS << ".long"; break;
|
||||
case 8: OS << ".quad"; break;
|
||||
}
|
||||
|
@ -10,6 +10,7 @@
|
||||
#include "gtest/gtest.h"
|
||||
#include "llvm/MC/MCContext.h"
|
||||
#include "llvm/MC/MCStreamer.h"
|
||||
#include "llvm/MC/MCValue.h"
|
||||
#include "llvm/Support/raw_ostream.h"
|
||||
using namespace llvm;
|
||||
|
||||
@ -49,4 +50,28 @@ TEST(AsmStreamer, Sections) {
|
||||
EXPECT_EQ(S.getString(), ".section foo\n");
|
||||
}
|
||||
|
||||
TEST(AsmStreamer, Values) {
|
||||
StringAsmStreamer S;
|
||||
MCSection *Sec0 = S.getContext().GetSection("foo");
|
||||
MCSymbol *A = S.getContext().CreateSymbol(S.getContext().CreateAtom(Sec0),
|
||||
"a");
|
||||
MCSymbol *B = S.getContext().CreateSymbol(S.getContext().CreateAtom(Sec0),
|
||||
"b");
|
||||
S.getStreamer().SwitchSection(Sec0);
|
||||
S.getStreamer().EmitLabel(A);
|
||||
S.getStreamer().EmitLabel(B);
|
||||
S.getStreamer().EmitValue(MCValue::get(A, B, 10), 1);
|
||||
S.getStreamer().EmitValue(MCValue::get(A, B, 10), 2);
|
||||
S.getStreamer().EmitValue(MCValue::get(A, B, 10), 4);
|
||||
S.getStreamer().EmitValue(MCValue::get(A, B, 10), 8);
|
||||
EXPECT_EQ(S.getString(), ".section foo\n\
|
||||
a:\n\
|
||||
b:\n\
|
||||
.byte a - b + 10\n\
|
||||
.short a - b + 10\n\
|
||||
.long a - b + 10\n\
|
||||
.quad a - b + 10\n\
|
||||
");
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user