Shiva Chen | 056d835 | 2018-01-26 07:53:07 +0000 | [diff] [blame] | 1 | //===-- RISCVELFStreamer.cpp - RISCV ELF Target Streamer Methods ----------===// |
| 2 | // |
Chandler Carruth | 2946cd7 | 2019-01-19 08:50:56 +0000 | [diff] [blame] | 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 |
Shiva Chen | 056d835 | 2018-01-26 07:53:07 +0000 | [diff] [blame] | 6 | // |
| 7 | //===----------------------------------------------------------------------===// |
| 8 | // |
| 9 | // This file provides RISCV specific target streamer methods. |
| 10 | // |
| 11 | //===----------------------------------------------------------------------===// |
| 12 | |
| 13 | #include "RISCVELFStreamer.h" |
Alex Bradbury | fea4957 | 2019-03-09 09:28:06 +0000 | [diff] [blame^] | 14 | #include "MCTargetDesc/RISCVAsmBackend.h" |
Shiva Chen | 056d835 | 2018-01-26 07:53:07 +0000 | [diff] [blame] | 15 | #include "RISCVMCTargetDesc.h" |
Alex Bradbury | fea4957 | 2019-03-09 09:28:06 +0000 | [diff] [blame^] | 16 | #include "Utils/RISCVBaseInfo.h" |
Shiva Chen | 056d835 | 2018-01-26 07:53:07 +0000 | [diff] [blame] | 17 | #include "llvm/BinaryFormat/ELF.h" |
| 18 | #include "llvm/MC/MCSubtargetInfo.h" |
| 19 | |
| 20 | using namespace llvm; |
| 21 | |
| 22 | // This part is for ELF object output. |
| 23 | RISCVTargetELFStreamer::RISCVTargetELFStreamer(MCStreamer &S, |
| 24 | const MCSubtargetInfo &STI) |
| 25 | : RISCVTargetStreamer(S) { |
| 26 | MCAssembler &MCA = getStreamer().getAssembler(); |
Shiva Chen | 056d835 | 2018-01-26 07:53:07 +0000 | [diff] [blame] | 27 | const FeatureBitset &Features = STI.getFeatureBits(); |
Alex Bradbury | fea4957 | 2019-03-09 09:28:06 +0000 | [diff] [blame^] | 28 | auto &MAB = static_cast<RISCVAsmBackend &>(MCA.getBackend()); |
| 29 | RISCVABI::ABI ABI = MAB.getTargetABI(); |
| 30 | assert(ABI != RISCVABI::ABI_Unknown && "Improperly initialised target ABI"); |
Shiva Chen | 056d835 | 2018-01-26 07:53:07 +0000 | [diff] [blame] | 31 | |
| 32 | unsigned EFlags = MCA.getELFHeaderEFlags(); |
| 33 | |
| 34 | if (Features[RISCV::FeatureStdExtC]) |
| 35 | EFlags |= ELF::EF_RISCV_RVC; |
| 36 | |
Alex Bradbury | fea4957 | 2019-03-09 09:28:06 +0000 | [diff] [blame^] | 37 | switch (ABI) { |
| 38 | case RISCVABI::ABI_ILP32: |
| 39 | case RISCVABI::ABI_LP64: |
| 40 | break; |
| 41 | case RISCVABI::ABI_ILP32F: |
| 42 | case RISCVABI::ABI_LP64F: |
| 43 | EFlags |= ELF::EF_RISCV_FLOAT_ABI_SINGLE; |
| 44 | break; |
| 45 | case RISCVABI::ABI_ILP32D: |
| 46 | case RISCVABI::ABI_LP64D: |
| 47 | EFlags |= ELF::EF_RISCV_FLOAT_ABI_DOUBLE; |
| 48 | break; |
| 49 | case RISCVABI::ABI_ILP32E: |
| 50 | EFlags |= ELF::EF_RISCV_RVE; |
| 51 | break; |
| 52 | case RISCVABI::ABI_Unknown: |
| 53 | llvm_unreachable("Improperly initialised target ABI"); |
| 54 | } |
| 55 | |
Shiva Chen | 056d835 | 2018-01-26 07:53:07 +0000 | [diff] [blame] | 56 | MCA.setELFHeaderEFlags(EFlags); |
| 57 | } |
| 58 | |
| 59 | MCELFStreamer &RISCVTargetELFStreamer::getStreamer() { |
| 60 | return static_cast<MCELFStreamer &>(Streamer); |
| 61 | } |
Alex Bradbury | bca0c3c | 2018-05-11 17:30:28 +0000 | [diff] [blame] | 62 | |
Alex Bradbury | 893e5bc | 2018-11-28 16:39:14 +0000 | [diff] [blame] | 63 | void RISCVTargetELFStreamer::emitDirectiveOptionPush() {} |
| 64 | void RISCVTargetELFStreamer::emitDirectiveOptionPop() {} |
Alex Bradbury | bca0c3c | 2018-05-11 17:30:28 +0000 | [diff] [blame] | 65 | void RISCVTargetELFStreamer::emitDirectiveOptionRVC() {} |
| 66 | void RISCVTargetELFStreamer::emitDirectiveOptionNoRVC() {} |
Alex Bradbury | 9c03e4c | 2018-11-12 14:25:07 +0000 | [diff] [blame] | 67 | void RISCVTargetELFStreamer::emitDirectiveOptionRelax() {} |
| 68 | void RISCVTargetELFStreamer::emitDirectiveOptionNoRelax() {} |