Path: blob/main/contrib/llvm-project/llvm/lib/Target/Mips/MCTargetDesc/MipsABIFlagsSection.cpp
35294 views
//===- MipsABIFlagsSection.cpp - Mips ELF ABI Flags Section ---------------===//1//2// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.3// See https://llvm.org/LICENSE.txt for license information.4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception5//6//===----------------------------------------------------------------------===//78#include "MCTargetDesc/MipsABIFlagsSection.h"9#include "llvm/ADT/StringRef.h"10#include "llvm/MC/MCStreamer.h"11#include "llvm/Support/ErrorHandling.h"12#include "llvm/Support/MipsABIFlags.h"1314using namespace llvm;1516uint8_t MipsABIFlagsSection::getFpABIValue() {17switch (FpABI) {18case FpABIKind::ANY:19return Mips::Val_GNU_MIPS_ABI_FP_ANY;20case FpABIKind::SOFT:21return Mips::Val_GNU_MIPS_ABI_FP_SOFT;22case FpABIKind::XX:23return Mips::Val_GNU_MIPS_ABI_FP_XX;24case FpABIKind::S32:25return Mips::Val_GNU_MIPS_ABI_FP_DOUBLE;26case FpABIKind::S64:27if (Is32BitABI)28return OddSPReg ? Mips::Val_GNU_MIPS_ABI_FP_6429: Mips::Val_GNU_MIPS_ABI_FP_64A;30return Mips::Val_GNU_MIPS_ABI_FP_DOUBLE;31}3233llvm_unreachable("unexpected fp abi value");34}3536StringRef MipsABIFlagsSection::getFpABIString(FpABIKind Value) {37switch (Value) {38case FpABIKind::XX:39return "xx";40case FpABIKind::S32:41return "32";42case FpABIKind::S64:43return "64";44default:45llvm_unreachable("unsupported fp abi value");46}47}4849uint8_t MipsABIFlagsSection::getCPR1SizeValue() {50if (FpABI == FpABIKind::XX)51return (uint8_t)Mips::AFL_REG_32;52return (uint8_t)CPR1Size;53}5455namespace llvm {5657MCStreamer &operator<<(MCStreamer &OS, MipsABIFlagsSection &ABIFlagsSection) {58// Write out a Elf_Internal_ABIFlags_v0 struct59OS.emitIntValue(ABIFlagsSection.getVersionValue(), 2); // version60OS.emitIntValue(ABIFlagsSection.getISALevelValue(), 1); // isa_level61OS.emitIntValue(ABIFlagsSection.getISARevisionValue(), 1); // isa_rev62OS.emitIntValue(ABIFlagsSection.getGPRSizeValue(), 1); // gpr_size63OS.emitIntValue(ABIFlagsSection.getCPR1SizeValue(), 1); // cpr1_size64OS.emitIntValue(ABIFlagsSection.getCPR2SizeValue(), 1); // cpr2_size65OS.emitIntValue(ABIFlagsSection.getFpABIValue(), 1); // fp_abi66OS.emitIntValue(ABIFlagsSection.getISAExtensionValue(), 4); // isa_ext67OS.emitIntValue(ABIFlagsSection.getASESetValue(), 4); // ases68OS.emitIntValue(ABIFlagsSection.getFlags1Value(), 4); // flags169OS.emitIntValue(ABIFlagsSection.getFlags2Value(), 4); // flags270return OS;71}7273} // end namespace llvm747576