LLVM  8.0.1
AArch64TargetStreamer.cpp
Go to the documentation of this file.
1 //===- AArch64TargetStreamer.cpp - AArch64TargetStreamer class ------------===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file implements the AArch64TargetStreamer class.
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #include "AArch64TargetStreamer.h"
15 #include "llvm/MC/ConstantPools.h"
17 
18 using namespace llvm;
19 
20 //
21 // AArch64TargetStreamer Implemenation
22 //
24  : MCTargetStreamer(S), ConstantPools(new AssemblerConstantPools()) {}
25 
27 
28 // The constant pool handling is shared by all AArch64TargetStreamer
29 // implementations.
31  unsigned Size,
32  SMLoc Loc) {
33  return ConstantPools->addEntry(Streamer, Expr, Size, Loc);
34 }
35 
37  ConstantPools->emitForCurrentSection(Streamer);
38 }
39 
40 // finish() - write out any non-empty assembler constant pools.
41 void AArch64TargetStreamer::finish() { ConstantPools->emitAll(Streamer); }
42 
44  char Buffer[4];
45 
46  // We can't just use EmitIntValue here, as that will swap the
47  // endianness on big-endian systems (instructions are always
48  // little-endian).
49  for (unsigned I = 0; I < 4; ++I) {
50  Buffer[I] = uint8_t(Inst);
51  Inst >>= 8;
52  }
53 
54  getStreamer().EmitBytes(StringRef(Buffer, 4));
55 }
56 
57 namespace llvm {
58 
61  const Triple &TT = STI.getTargetTriple();
62  if (TT.isOSBinFormatELF())
63  return new AArch64TargetELFStreamer(S);
64  if (TT.isOSBinFormatCOFF())
65  return new AArch64TargetWinCOFFStreamer(S);
66  return nullptr;
67 }
68 
69 } // end namespace llvm
This class represents lattice values for constants.
Definition: AllocatorList.h:24
bool isOSBinFormatELF() const
Tests whether the OS uses the ELF binary format.
Definition: Triple.h:604
virtual void EmitBytes(StringRef Data)
Emit the bytes in Data into the output.
Target specific streamer interface.
Definition: MCStreamer.h:84
virtual void emitInst(uint32_t Inst)
Callback used to implement the .inst directive.
const Triple & getTargetTriple() const
Base class for the full range of assembler expressions which are needed for parsing.
Definition: MCExpr.h:36
const MCExpr * addConstantPoolEntry(const MCExpr *, unsigned Size, SMLoc Loc)
Callback used to implement the ldr= pseudo.
Streaming machine code generation interface.
Definition: MCStreamer.h:189
bool isOSBinFormatCOFF() const
Tests whether the OS uses the COFF binary format.
Definition: Triple.h:609
Triple - Helper class for working with autoconf configuration names.
Definition: Triple.h:44
MCTargetStreamer * createAArch64ObjectTargetStreamer(MCStreamer &S, const MCSubtargetInfo &STI)
MCStreamer & getStreamer()
Definition: MCStreamer.h:92
MCStreamer & Streamer
Definition: MCStreamer.h:86
#define I(x, y, z)
Definition: MD5.cpp:58
Generic base class for all target subtargets.
uint32_t Size
Definition: Profile.cpp:47
void emitCurrentConstantPool()
Callback used to implemnt the .ltorg directive.
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:49
Represents a location in source code.
Definition: SMLoc.h:24