brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.5 KiB · c5a1a3e Raw
75 lines · cpp
1//===- MipsABIFlagsSection.cpp - Mips ELF ABI Flags Section ---------------===//2//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-exception6//7//===----------------------------------------------------------------------===//8 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"14 15using namespace llvm;16 17uint8_t MipsABIFlagsSection::getFpABIValue() {18  switch (FpABI) {19  case FpABIKind::ANY:20    return Mips::Val_GNU_MIPS_ABI_FP_ANY;21  case FpABIKind::SOFT:22    return Mips::Val_GNU_MIPS_ABI_FP_SOFT;23  case FpABIKind::XX:24    return Mips::Val_GNU_MIPS_ABI_FP_XX;25  case FpABIKind::S32:26    return Mips::Val_GNU_MIPS_ABI_FP_DOUBLE;27  case FpABIKind::S64:28    if (Is32BitABI)29      return OddSPReg ? Mips::Val_GNU_MIPS_ABI_FP_6430                      : Mips::Val_GNU_MIPS_ABI_FP_64A;31    return Mips::Val_GNU_MIPS_ABI_FP_DOUBLE;32  }33 34  llvm_unreachable("unexpected fp abi value");35}36 37StringRef MipsABIFlagsSection::getFpABIString(FpABIKind Value) {38  switch (Value) {39  case FpABIKind::XX:40    return "xx";41  case FpABIKind::S32:42    return "32";43  case FpABIKind::S64:44    return "64";45  default:46    llvm_unreachable("unsupported fp abi value");47  }48}49 50uint8_t MipsABIFlagsSection::getCPR1SizeValue() {51  if (FpABI == FpABIKind::XX)52    return (uint8_t)Mips::AFL_REG_32;53  return (uint8_t)CPR1Size;54}55 56namespace llvm {57 58MCStreamer &operator<<(MCStreamer &OS, MipsABIFlagsSection &ABIFlagsSection) {59  // Write out a Elf_Internal_ABIFlags_v0 struct60  OS.emitIntValue(ABIFlagsSection.getVersionValue(), 2);      // version61  OS.emitIntValue(ABIFlagsSection.getISALevelValue(), 1);     // isa_level62  OS.emitIntValue(ABIFlagsSection.getISARevisionValue(), 1);  // isa_rev63  OS.emitIntValue(ABIFlagsSection.getGPRSizeValue(), 1);      // gpr_size64  OS.emitIntValue(ABIFlagsSection.getCPR1SizeValue(), 1);     // cpr1_size65  OS.emitIntValue(ABIFlagsSection.getCPR2SizeValue(), 1);     // cpr2_size66  OS.emitIntValue(ABIFlagsSection.getFpABIValue(), 1);        // fp_abi67  OS.emitIntValue(ABIFlagsSection.getISAExtensionValue(), 4); // isa_ext68  OS.emitIntValue(ABIFlagsSection.getASESetValue(), 4);       // ases69  OS.emitIntValue(ABIFlagsSection.getFlags1Value(), 4);       // flags170  OS.emitIntValue(ABIFlagsSection.getFlags2Value(), 4);       // flags271  return OS;72}73 74} // end namespace llvm75