brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.9 KiB · e156fa0 Raw
93 lines · cpp
1//===- MCAsmInfoDarwin.cpp - Darwin asm properties ------------------------===//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// This file defines target asm properties related what form asm statements10// should take in general on Darwin-based targets11//12//===----------------------------------------------------------------------===//13 14#include "llvm/MC/MCAsmInfoDarwin.h"15#include "llvm/BinaryFormat/MachO.h"16#include "llvm/MC/MCDirectives.h"17#include "llvm/MC/MCSectionMachO.h"18 19using namespace llvm;20 21bool MCAsmInfoDarwin::isSectionAtomizableBySymbols(22    const MCSection &Section) {23  const MCSectionMachO &SMO = static_cast<const MCSectionMachO &>(Section);24 25  // Sections holding 1 byte strings are atomized based on the data they26  // contain.27  // Sections holding 2 byte strings require symbols in order to be atomized.28  // There is no dedicated section for 4 byte strings.29  if (SMO.getType() == MachO::S_CSTRING_LITERALS)30    return false;31 32  if (SMO.getSegmentName() == "__DATA" && SMO.getName() == "__cfstring")33    return false;34 35  if (SMO.getSegmentName() == "__DATA" && SMO.getName() == "__objc_classrefs")36    return false;37 38  switch (SMO.getType()) {39  default:40    return true;41 42  // These sections are atomized at the element boundaries without using43  // symbols.44  case MachO::S_4BYTE_LITERALS:45  case MachO::S_8BYTE_LITERALS:46  case MachO::S_16BYTE_LITERALS:47  case MachO::S_LITERAL_POINTERS:48  case MachO::S_NON_LAZY_SYMBOL_POINTERS:49  case MachO::S_LAZY_SYMBOL_POINTERS:50  case MachO::S_THREAD_LOCAL_VARIABLE_POINTERS:51  case MachO::S_MOD_INIT_FUNC_POINTERS:52  case MachO::S_MOD_TERM_FUNC_POINTERS:53  case MachO::S_INTERPOSING:54    return false;55  }56}57 58MCAsmInfoDarwin::MCAsmInfoDarwin() {59  // Common settings for all Darwin targets.60  // Syntax:61  LinkerPrivateGlobalPrefix = "l";62  HasSingleParameterDotFile = false;63  HasSubsectionsViaSymbols = true;64 65  AlignmentIsInBytes = false;66  COMMDirectiveAlignmentIsInBytes = false;67  LCOMMDirectiveAlignmentType = LCOMM::Log2Alignment;68  InlineAsmStart = " InlineAsm Start";69  InlineAsmEnd = " InlineAsm End";70 71  // Directives:72  HasWeakDefCanBeHiddenDirective = true;73  WeakRefDirective = "\t.weak_reference ";74  ZeroDirective = "\t.space\t";  // ".space N" emits N zeros.75 76  HiddenVisibilityAttr = MCSA_PrivateExtern;77  HiddenDeclarationVisibilityAttr = MCSA_Invalid;78 79  // Doesn't support protected visibility.80  ProtectedVisibilityAttr = MCSA_Invalid;81 82  HasDotTypeDotSizeDirective = false;83  HasNoDeadStrip = true;84 85  DwarfUsesRelocationsAcrossSections = false;86  SetDirectiveSuppressesReloc = true;87}88 89bool MCAsmInfoDarwin::useCodeAlign(const MCSection &Sec) const {90  return static_cast<const MCSectionMachO &>(Sec).hasAttribute(91      MachO::S_ATTR_PURE_INSTRUCTIONS);92}93