Daniel Sanders | c7dbc63 | 2014-07-08 10:11:38 +0000 | [diff] [blame] | 1 | //===-- MipsABIFlagsSection.cpp - Mips ELF ABI Flags Section ---*- C++ -*--===// |
| 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 | #include "MipsABIFlagsSection.h" |
| 11 | |
| 12 | using namespace llvm; |
| 13 | |
Daniel Sanders | 7e52742 | 2014-07-10 13:38:23 +0000 | [diff] [blame^] | 14 | uint8_t MipsABIFlagsSection::getFpABIValue() { |
| 15 | switch (FpABI) { |
| 16 | case FpABIKind::ANY: |
| 17 | return Val_GNU_MIPS_ABI_FP_ANY; |
| 18 | case FpABIKind::XX: |
| 19 | return Val_GNU_MIPS_ABI_FP_XX; |
| 20 | case FpABIKind::S32: |
| 21 | return Val_GNU_MIPS_ABI_FP_DOUBLE; |
| 22 | case FpABIKind::S64: |
| 23 | if (Is32BitABI) |
| 24 | return OddSPReg ? Val_GNU_MIPS_ABI_FP_64 : Val_GNU_MIPS_ABI_FP_64A; |
| 25 | return Val_GNU_MIPS_ABI_FP_DOUBLE; |
| 26 | default: |
| 27 | return 0; |
| 28 | } |
| 29 | } |
| 30 | |
| 31 | StringRef MipsABIFlagsSection::getFpABIString(FpABIKind Value) { |
Daniel Sanders | c7dbc63 | 2014-07-08 10:11:38 +0000 | [diff] [blame] | 32 | switch (Value) { |
Daniel Sanders | 7e52742 | 2014-07-10 13:38:23 +0000 | [diff] [blame^] | 33 | case FpABIKind::XX: |
Daniel Sanders | c7dbc63 | 2014-07-08 10:11:38 +0000 | [diff] [blame] | 34 | return "xx"; |
Daniel Sanders | 7e52742 | 2014-07-10 13:38:23 +0000 | [diff] [blame^] | 35 | case FpABIKind::S32: |
| 36 | return "32"; |
| 37 | case FpABIKind::S64: |
Daniel Sanders | c7dbc63 | 2014-07-08 10:11:38 +0000 | [diff] [blame] | 38 | return "64"; |
| 39 | default: |
| 40 | llvm_unreachable("unsupported fp abi value"); |
| 41 | } |
| 42 | } |
| 43 | |
| 44 | namespace llvm { |
| 45 | MCStreamer &operator<<(MCStreamer &OS, MipsABIFlagsSection &ABIFlagsSection) { |
| 46 | // Write out a Elf_Internal_ABIFlags_v0 struct |
Daniel Sanders | 7e52742 | 2014-07-10 13:38:23 +0000 | [diff] [blame^] | 47 | OS.EmitIntValue(ABIFlagsSection.getVersionValue(), 2); // version |
| 48 | OS.EmitIntValue(ABIFlagsSection.getISALevelValue(), 1); // isa_level |
| 49 | OS.EmitIntValue(ABIFlagsSection.getISARevisionValue(), 1); // isa_rev |
| 50 | OS.EmitIntValue(ABIFlagsSection.getGPRSizeValue(), 1); // gpr_size |
| 51 | OS.EmitIntValue(ABIFlagsSection.getCPR1SizeValue(), 1); // cpr1_size |
| 52 | OS.EmitIntValue(ABIFlagsSection.getCPR2SizeValue(), 1); // cpr2_size |
| 53 | OS.EmitIntValue(ABIFlagsSection.getFpABIValue(), 1); // fp_abi |
| 54 | OS.EmitIntValue(ABIFlagsSection.getISAExtensionSetValue(), 4); // isa_ext |
| 55 | OS.EmitIntValue(ABIFlagsSection.getASESetValue(), 4); // ases |
| 56 | OS.EmitIntValue(ABIFlagsSection.getFlags1Value(), 4); // flags1 |
| 57 | OS.EmitIntValue(ABIFlagsSection.getFlags2Value(), 4); // flags2 |
Daniel Sanders | c7dbc63 | 2014-07-08 10:11:38 +0000 | [diff] [blame] | 58 | return OS; |
| 59 | } |
| 60 | } |