/src/keystone/llvm/lib/Target/RISCV/MCTargetDesc/RISCVELFStreamer.cpp
Line | Count | Source |
1 | | //===-- RISCVELFStreamer.cpp - RISCV ELF Target Streamer Methods ----------===// |
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 provides RISCV specific target streamer methods. |
10 | | // |
11 | | //===----------------------------------------------------------------------===// |
12 | | |
13 | | #include "RISCVELFStreamer.h" |
14 | | #include "MCTargetDesc/RISCVAsmBackend.h" |
15 | | #include "RISCVMCTargetDesc.h" |
16 | | #include "Utils/RISCVBaseInfo.h" |
17 | | #include "llvm/Support/ELF.h" |
18 | | #include "llvm/MC/MCSubtargetInfo.h" |
19 | | |
20 | | using namespace llvm_ks; |
21 | | |
22 | | // This part is for ELF object output. |
23 | | RISCVTargetELFStreamer::RISCVTargetELFStreamer(MCStreamer &S, |
24 | | const MCSubtargetInfo &STI) |
25 | 25.5k | : RISCVTargetStreamer(S) { |
26 | 25.5k | MCAssembler &MCA = getStreamer().getAssembler(); |
27 | 25.5k | const FeatureBitset &Features = STI.getFeatureBits(); |
28 | 25.5k | auto &MAB = static_cast<RISCVAsmBackend &>(MCA.getBackend()); |
29 | 25.5k | RISCVABI::ABI ABI = MAB.getTargetABI(); |
30 | 25.5k | assert(ABI != RISCVABI::ABI_Unknown && "Improperly initialised target ABI"); |
31 | 25.5k | RISCVFeatures::validate(STI.getTargetTriple(), STI.getFeatureBits()); |
32 | | |
33 | 25.5k | unsigned EFlags = MCA.getELFHeaderEFlags(); |
34 | | |
35 | 25.5k | if (Features[RISCV::FeatureStdExtC]) |
36 | 25.5k | EFlags |= ELF::EF_RISCV_RVC; |
37 | | |
38 | 25.5k | switch (ABI) { |
39 | 13.1k | case RISCVABI::ABI_ILP32: |
40 | 25.5k | case RISCVABI::ABI_LP64: |
41 | 25.5k | break; |
42 | 0 | case RISCVABI::ABI_ILP32F: |
43 | 0 | case RISCVABI::ABI_LP64F: |
44 | 0 | EFlags |= ELF::EF_RISCV_FLOAT_ABI_SINGLE; |
45 | 0 | break; |
46 | 0 | case RISCVABI::ABI_ILP32D: |
47 | 0 | case RISCVABI::ABI_LP64D: |
48 | 0 | EFlags |= ELF::EF_RISCV_FLOAT_ABI_DOUBLE; |
49 | 0 | break; |
50 | 0 | case RISCVABI::ABI_ILP32E: |
51 | 0 | EFlags |= ELF::EF_RISCV_RVE; |
52 | 0 | break; |
53 | 0 | case RISCVABI::ABI_Unknown: |
54 | 0 | llvm_unreachable("Improperly initialised target ABI"); |
55 | 25.5k | } |
56 | | |
57 | 25.5k | MCA.setELFHeaderEFlags(EFlags); |
58 | 25.5k | } |
59 | | |
60 | 25.5k | MCELFStreamer &RISCVTargetELFStreamer::getStreamer() { |
61 | 25.5k | return static_cast<MCELFStreamer &>(Streamer); |
62 | 25.5k | } |
63 | | |
64 | 0 | void RISCVTargetELFStreamer::emitDirectiveOptionPush() {} |
65 | 0 | void RISCVTargetELFStreamer::emitDirectiveOptionPop() {} |
66 | 0 | void RISCVTargetELFStreamer::emitDirectiveOptionRVC() {} |
67 | 0 | void RISCVTargetELFStreamer::emitDirectiveOptionNoRVC() {} |
68 | 0 | void RISCVTargetELFStreamer::emitDirectiveOptionRelax() {} |
69 | 0 | void RISCVTargetELFStreamer::emitDirectiveOptionNoRelax() {} |