1 //===- MipsABIFlagsSection.cpp - Mips ELF ABI Flags Section ---------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #include "MCTargetDesc/MipsABIFlagsSection.h"
11 #include "llvm/ADT/StringRef.h"
12 #include "llvm/MC/MCStreamer.h"
13 #include "llvm/Support/ErrorHandling.h"
14 #include "llvm/Support/MipsABIFlags.h"
18 uint8_t MipsABIFlagsSection::getFpABIValue() {
21 return Mips::Val_GNU_MIPS_ABI_FP_ANY;
23 return Mips::Val_GNU_MIPS_ABI_FP_SOFT;
25 return Mips::Val_GNU_MIPS_ABI_FP_XX;
27 return Mips::Val_GNU_MIPS_ABI_FP_DOUBLE;
30 return OddSPReg ? Mips::Val_GNU_MIPS_ABI_FP_64
31 : Mips::Val_GNU_MIPS_ABI_FP_64A;
32 return Mips::Val_GNU_MIPS_ABI_FP_DOUBLE;
35 llvm_unreachable("unexpected fp abi value");
38 StringRef MipsABIFlagsSection::getFpABIString(FpABIKind Value) {
47 llvm_unreachable("unsupported fp abi value");
51 uint8_t MipsABIFlagsSection::getCPR1SizeValue() {
52 if (FpABI == FpABIKind::XX)
53 return (uint8_t)Mips::AFL_REG_32;
54 return (uint8_t)CPR1Size;
59 MCStreamer &operator<<(MCStreamer &OS, MipsABIFlagsSection &ABIFlagsSection) {
60 // Write out a Elf_Internal_ABIFlags_v0 struct
61 OS.EmitIntValue(ABIFlagsSection.getVersionValue(), 2); // version
62 OS.EmitIntValue(ABIFlagsSection.getISALevelValue(), 1); // isa_level
63 OS.EmitIntValue(ABIFlagsSection.getISARevisionValue(), 1); // isa_rev
64 OS.EmitIntValue(ABIFlagsSection.getGPRSizeValue(), 1); // gpr_size
65 OS.EmitIntValue(ABIFlagsSection.getCPR1SizeValue(), 1); // cpr1_size
66 OS.EmitIntValue(ABIFlagsSection.getCPR2SizeValue(), 1); // cpr2_size
67 OS.EmitIntValue(ABIFlagsSection.getFpABIValue(), 1); // fp_abi
68 OS.EmitIntValue(ABIFlagsSection.getISAExtensionValue(), 4); // isa_ext
69 OS.EmitIntValue(ABIFlagsSection.getASESetValue(), 4); // ases
70 OS.EmitIntValue(ABIFlagsSection.getFlags1Value(), 4); // flags1
71 OS.EmitIntValue(ABIFlagsSection.getFlags2Value(), 4); // flags2
75 } // end namespace llvm