xref: /aosp_15_r20/external/llvm/lib/Target/AVR/AVRTargetObjectFile.cpp (revision 9880d6810fe72a1726cb53787c6711e909410d58)
1*9880d681SAndroid Build Coastguard Worker //===-- AVRTargetObjectFile.cpp - AVR Object Files ------------------------===//
2*9880d681SAndroid Build Coastguard Worker //
3*9880d681SAndroid Build Coastguard Worker //                     The LLVM Compiler Infrastructure
4*9880d681SAndroid Build Coastguard Worker //
5*9880d681SAndroid Build Coastguard Worker // This file is distributed under the University of Illinois Open Source
6*9880d681SAndroid Build Coastguard Worker // License. See LICENSE.TXT for details.
7*9880d681SAndroid Build Coastguard Worker //
8*9880d681SAndroid Build Coastguard Worker //===----------------------------------------------------------------------===//
9*9880d681SAndroid Build Coastguard Worker 
10*9880d681SAndroid Build Coastguard Worker #include "AVRTargetObjectFile.h"
11*9880d681SAndroid Build Coastguard Worker 
12*9880d681SAndroid Build Coastguard Worker #include "llvm/IR/DerivedTypes.h"
13*9880d681SAndroid Build Coastguard Worker #include "llvm/IR/GlobalValue.h"
14*9880d681SAndroid Build Coastguard Worker #include "llvm/IR/Mangler.h"
15*9880d681SAndroid Build Coastguard Worker #include "llvm/MC/MCContext.h"
16*9880d681SAndroid Build Coastguard Worker #include "llvm/MC/MCSectionELF.h"
17*9880d681SAndroid Build Coastguard Worker #include "llvm/Support/ELF.h"
18*9880d681SAndroid Build Coastguard Worker 
19*9880d681SAndroid Build Coastguard Worker #include "AVR.h"
20*9880d681SAndroid Build Coastguard Worker 
21*9880d681SAndroid Build Coastguard Worker namespace llvm {
Initialize(MCContext & Ctx,const TargetMachine & TM)22*9880d681SAndroid Build Coastguard Worker void AVRTargetObjectFile::Initialize(MCContext &Ctx, const TargetMachine &TM) {
23*9880d681SAndroid Build Coastguard Worker   Base::Initialize(Ctx, TM);
24*9880d681SAndroid Build Coastguard Worker   ProgmemDataSection =
25*9880d681SAndroid Build Coastguard Worker       Ctx.getELFSection(".progmem.data", ELF::SHT_PROGBITS, ELF::SHF_ALLOC);
26*9880d681SAndroid Build Coastguard Worker }
27*9880d681SAndroid Build Coastguard Worker 
28*9880d681SAndroid Build Coastguard Worker MCSection *
SelectSectionForGlobal(const GlobalValue * GV,SectionKind Kind,Mangler & Mang,const TargetMachine & TM) const29*9880d681SAndroid Build Coastguard Worker AVRTargetObjectFile::SelectSectionForGlobal(const GlobalValue *GV,
30*9880d681SAndroid Build Coastguard Worker                                             SectionKind Kind, Mangler &Mang,
31*9880d681SAndroid Build Coastguard Worker                                             const TargetMachine &TM) const {
32*9880d681SAndroid Build Coastguard Worker   // Global values in flash memory are placed in the progmem.data section
33*9880d681SAndroid Build Coastguard Worker   // unless they already have a user assigned section.
34*9880d681SAndroid Build Coastguard Worker   if (AVR::isProgramMemoryAddress(GV) && !GV->hasSection())
35*9880d681SAndroid Build Coastguard Worker     return ProgmemDataSection;
36*9880d681SAndroid Build Coastguard Worker 
37*9880d681SAndroid Build Coastguard Worker   // Otherwise, we work the same way as ELF.
38*9880d681SAndroid Build Coastguard Worker   return Base::SelectSectionForGlobal(GV, Kind, Mang, TM);
39*9880d681SAndroid Build Coastguard Worker }
40*9880d681SAndroid Build Coastguard Worker } // end of namespace llvm
41