LLVM  14.0.0git
AVRTargetObjectFile.cpp
Go to the documentation of this file.
1 //===-- AVRTargetObjectFile.cpp - AVR Object Files ------------------------===//
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-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #include "AVRTargetObjectFile.h"
10 
11 #include "llvm/BinaryFormat/ELF.h"
12 #include "llvm/IR/DerivedTypes.h"
13 #include "llvm/IR/GlobalValue.h"
14 #include "llvm/IR/Mangler.h"
15 #include "llvm/MC/MCContext.h"
16 #include "llvm/MC/MCSectionELF.h"
17 
18 #include "AVR.h"
19 
20 namespace llvm {
22  Base::Initialize(Ctx, TM);
23  ProgmemDataSection =
24  Ctx.getELFSection(".progmem.data", ELF::SHT_PROGBITS, ELF::SHF_ALLOC);
25 }
26 
28  const GlobalObject *GO, SectionKind Kind, const TargetMachine &TM) const {
29  // Global values in flash memory are placed in the progmem.data section
30  // unless they already have a user assigned section.
31  if (AVR::isProgramMemoryAddress(GO) && !GO->hasSection() && Kind.isReadOnly())
32  return ProgmemDataSection;
33 
34  // Otherwise, we work the same way as ELF.
36 }
37 } // end of namespace llvm
llvm
---------------------— PointerInfo ------------------------------------—
Definition: AllocatorList.h:23
llvm::TargetLoweringObjectFileELF::SelectSectionForGlobal
MCSection * SelectSectionForGlobal(const GlobalObject *GO, SectionKind Kind, const TargetMachine &TM) const override
Definition: TargetLoweringObjectFileImpl.cpp:874
llvm::MCContext
Context object for machine code objects.
Definition: MCContext.h:72
MCSectionELF.h
llvm::ELF::SHT_PROGBITS
@ SHT_PROGBITS
Definition: ELF.h:910
GlobalValue.h
ELF.h
llvm::AVRTargetObjectFile::Initialize
void Initialize(MCContext &ctx, const TargetMachine &TM) override
This method must be called before any actual lowering is done.
Definition: AVRTargetObjectFile.cpp:21
llvm::GlobalObject
Definition: GlobalObject.h:28
MCContext.h
llvm::MCContext::getELFSection
MCSectionELF * getELFSection(const Twine &Section, unsigned Type, unsigned Flags)
Definition: MCContext.h:540
llvm::lltok::Kind
Kind
Definition: LLToken.h:18
llvm::AVRTargetObjectFile::SelectSectionForGlobal
MCSection * SelectSectionForGlobal(const GlobalObject *GO, SectionKind Kind, const TargetMachine &TM) const override
Definition: AVRTargetObjectFile.cpp:27
llvm::TargetLoweringObjectFile::TM
const TargetMachine * TM
Definition: TargetLoweringObjectFile.h:66
llvm::GlobalObject::hasSection
bool hasSection() const
Check if this global has a custom object file section.
Definition: GlobalObject.h:104
llvm::TargetMachine
Primary interface to the complete machine description for the target machine.
Definition: TargetMachine.h:79
llvm::AVR::isProgramMemoryAddress
bool isProgramMemoryAddress(T *V)
Checks if a given type is a pointer to program memory.
Definition: AVR.h:45
Mangler.h
llvm::ELF::SHF_ALLOC
@ SHF_ALLOC
Definition: ELF.h:988
llvm::MCSection
Instances of this class represent a uniqued identifier for a section in the current translation unit.
Definition: MCSection.h:39
AVRTargetObjectFile.h
llvm::SectionKind
SectionKind - This is a simple POD value that classifies the properties of a section.
Definition: SectionKind.h:22
llvm::TargetLoweringObjectFileELF::Initialize
void Initialize(MCContext &Ctx, const TargetMachine &TM) override
This method must be called before any actual lowering is done.
Definition: TargetLoweringObjectFileImpl.cpp:116
AVR.h
DerivedTypes.h
TM
const char LLVMTargetMachineRef TM
Definition: PassBuilderBindings.cpp:47