1 //===- MipsABIFlagsSection.cpp - Mips ELF ABI Flags Section ---------------===//
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
7 //===----------------------------------------------------------------------===//
9 #include "MCTargetDesc/MipsABIFlagsSection.h"
10 #include "llvm/ADT/StringRef.h"
11 #include "llvm/MC/MCStreamer.h"
12 #include "llvm/Support/ErrorHandling.h"
13 #include "llvm/Support/MipsABIFlags.h"
17 uint8_t MipsABIFlagsSection::getFpABIValue() {
20 return Mips::Val_GNU_MIPS_ABI_FP_ANY
;
22 return Mips::Val_GNU_MIPS_ABI_FP_SOFT
;
24 return Mips::Val_GNU_MIPS_ABI_FP_XX
;
26 return Mips::Val_GNU_MIPS_ABI_FP_DOUBLE
;
29 return OddSPReg
? Mips::Val_GNU_MIPS_ABI_FP_64
30 : Mips::Val_GNU_MIPS_ABI_FP_64A
;
31 return Mips::Val_GNU_MIPS_ABI_FP_DOUBLE
;
34 llvm_unreachable("unexpected fp abi value");
37 StringRef
MipsABIFlagsSection::getFpABIString(FpABIKind Value
) {
46 llvm_unreachable("unsupported fp abi value");
50 uint8_t MipsABIFlagsSection::getCPR1SizeValue() {
51 if (FpABI
== FpABIKind::XX
)
52 return (uint8_t)Mips::AFL_REG_32
;
53 return (uint8_t)CPR1Size
;
58 MCStreamer
&operator<<(MCStreamer
&OS
, MipsABIFlagsSection
&ABIFlagsSection
) {
59 // Write out a Elf_Internal_ABIFlags_v0 struct
60 OS
.EmitIntValue(ABIFlagsSection
.getVersionValue(), 2); // version
61 OS
.EmitIntValue(ABIFlagsSection
.getISALevelValue(), 1); // isa_level
62 OS
.EmitIntValue(ABIFlagsSection
.getISARevisionValue(), 1); // isa_rev
63 OS
.EmitIntValue(ABIFlagsSection
.getGPRSizeValue(), 1); // gpr_size
64 OS
.EmitIntValue(ABIFlagsSection
.getCPR1SizeValue(), 1); // cpr1_size
65 OS
.EmitIntValue(ABIFlagsSection
.getCPR2SizeValue(), 1); // cpr2_size
66 OS
.EmitIntValue(ABIFlagsSection
.getFpABIValue(), 1); // fp_abi
67 OS
.EmitIntValue(ABIFlagsSection
.getISAExtensionValue(), 4); // isa_ext
68 OS
.EmitIntValue(ABIFlagsSection
.getASESetValue(), 4); // ases
69 OS
.EmitIntValue(ABIFlagsSection
.getFlags1Value(), 4); // flags1
70 OS
.EmitIntValue(ABIFlagsSection
.getFlags2Value(), 4); // flags2
74 } // end namespace llvm