diff options
-rw-r--r-- | lib/MC/MCAsmStreamer.cpp | 2 | ||||
-rw-r--r-- | unittests/MC/AsmStreamerTest.cpp | 25 |
2 files changed, 26 insertions, 1 deletions
diff --git a/lib/MC/MCAsmStreamer.cpp b/lib/MC/MCAsmStreamer.cpp index d268fb7..efc9e65 100644 --- a/lib/MC/MCAsmStreamer.cpp +++ b/lib/MC/MCAsmStreamer.cpp @@ -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; } diff --git a/unittests/MC/AsmStreamerTest.cpp b/unittests/MC/AsmStreamerTest.cpp index 80cd456..d973301 100644 --- a/unittests/MC/AsmStreamerTest.cpp +++ b/unittests/MC/AsmStreamerTest.cpp @@ -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\ +"); +} + } |