LLVM  10.0.0svn
AArch64TargetStreamer.cpp
Go to the documentation of this file.
1 //===- AArch64TargetStreamer.cpp - AArch64TargetStreamer class ------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file implements the AArch64TargetStreamer class.
10 //
11 //===----------------------------------------------------------------------===//
12 
13 #include "AArch64TargetStreamer.h"
14 #include "llvm/MC/ConstantPools.h"
15 #include "llvm/MC/MCSection.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:23
bool isOSBinFormatELF() const
Tests whether the OS uses the ELF binary format.
Definition: Triple.h:623
virtual void EmitBytes(StringRef Data)
Emit the bytes in Data into the output.
Target specific streamer interface.
Definition: MCStreamer.h:91
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:35
const MCExpr * addConstantPoolEntry(const MCExpr *, unsigned Size, SMLoc Loc)
Callback used to implement the ldr= pseudo.
Streaming machine code generation interface.
Definition: MCStreamer.h:196
bool isOSBinFormatCOFF() const
Tests whether the OS uses the COFF binary format.
Definition: Triple.h:628
Triple - Helper class for working with autoconf configuration names.
Definition: Triple.h:43
MCTargetStreamer * createAArch64ObjectTargetStreamer(MCStreamer &S, const MCSubtargetInfo &STI)
MCStreamer & getStreamer()
Definition: MCStreamer.h:99
MCStreamer & Streamer
Definition: MCStreamer.h:93
#define I(x, y, z)
Definition: MD5.cpp:58
Generic base class for all target subtargets.
uint32_t Size
Definition: Profile.cpp:46
void emitCurrentConstantPool()
Callback used to implemnt the .ltorg directive.
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:48
Represents a location in source code.
Definition: SMLoc.h:23