From 8e8de8f7765a08ab3aa4f48b302cf19ccb9740e2 Mon Sep 17 00:00:00 2001 From: Jim Laskey Date: Thu, 7 Sep 2006 22:05:02 +0000 Subject: [PATCH] Break out target asm info into separate files. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@30161 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Target/ARM/ARMTargetAsmInfo.cpp | 26 +++++++ lib/Target/ARM/ARMTargetAsmInfo.h | 31 ++++++++ lib/Target/Alpha/AlphaTargetAsmInfo.cpp | 21 ++++++ lib/Target/Alpha/AlphaTargetAsmInfo.h | 30 ++++++++ lib/Target/IA64/IA64TargetAsmInfo.cpp | 34 +++++++++ lib/Target/IA64/IA64TargetAsmInfo.h | 31 ++++++++ lib/Target/PowerPC/PPCTargetAsmInfo.cpp | 51 +++++++++++++ lib/Target/PowerPC/PPCTargetAsmInfo.h | 31 ++++++++ lib/Target/Sparc/SparcTargetAsmInfo.cpp | 25 +++++++ lib/Target/Sparc/SparcTargetAsmInfo.h | 31 ++++++++ lib/Target/X86/X86TargetAsmInfo.cpp | 95 +++++++++++++++++++++++++ lib/Target/X86/X86TargetAsmInfo.h | 31 ++++++++ 12 files changed, 437 insertions(+) create mode 100644 lib/Target/ARM/ARMTargetAsmInfo.cpp create mode 100644 lib/Target/ARM/ARMTargetAsmInfo.h create mode 100644 lib/Target/Alpha/AlphaTargetAsmInfo.cpp create mode 100644 lib/Target/Alpha/AlphaTargetAsmInfo.h create mode 100644 lib/Target/IA64/IA64TargetAsmInfo.cpp create mode 100644 lib/Target/IA64/IA64TargetAsmInfo.h create mode 100644 lib/Target/PowerPC/PPCTargetAsmInfo.cpp create mode 100644 lib/Target/PowerPC/PPCTargetAsmInfo.h create mode 100644 lib/Target/Sparc/SparcTargetAsmInfo.cpp create mode 100644 lib/Target/Sparc/SparcTargetAsmInfo.h create mode 100644 lib/Target/X86/X86TargetAsmInfo.cpp create mode 100644 lib/Target/X86/X86TargetAsmInfo.h diff --git a/lib/Target/ARM/ARMTargetAsmInfo.cpp b/lib/Target/ARM/ARMTargetAsmInfo.cpp new file mode 100644 index 00000000000..90db4666763 --- /dev/null +++ b/lib/Target/ARM/ARMTargetAsmInfo.cpp @@ -0,0 +1,26 @@ +//===-- ARMTargetAsmInfo.cpp - ARM asm properties ---------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by James M. Laskey and is distributed under the +// University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This file contains the declarations of the ARMTargetAsmInfo properties. +// +//===----------------------------------------------------------------------===// + +#include "ARMTargetAsmInfo.h" + +using namespace llvm; + +ARMTargetAsmInfo::ARMTargetAsmInfo(const ARMTargetMachine &TM) { + Data16bitsDirective = "\t.half\t"; + Data32bitsDirective = "\t.word\t"; + Data64bitsDirective = 0; + ZeroDirective = "\t.skip\t"; + CommentString = "@"; + ConstantPoolSection = "\t.text\n"; + AlignmentIsInBytes = false; +} diff --git a/lib/Target/ARM/ARMTargetAsmInfo.h b/lib/Target/ARM/ARMTargetAsmInfo.h new file mode 100644 index 00000000000..4edb1d2e431 --- /dev/null +++ b/lib/Target/ARM/ARMTargetAsmInfo.h @@ -0,0 +1,31 @@ +//=====-- ARMTargetAsmInfo.h - ARM asm properties -------------*- C++ -*--====// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by James M. Laskey and is distributed under the +// University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This file contains the declaration of the ARMTargetAsmInfo class. +// +//===----------------------------------------------------------------------===// + +#ifndef ARMTARGETASMINFO_H +#define ARMTARGETASMINFO_H + +#include "llvm/Target/TargetAsmInfo.h" + +namespace llvm { + + // Forward declaration. + class ARMTargetMachine; + + struct ARMTargetAsmInfo : public TargetAsmInfo { + ARMTargetAsmInfo(const ARMTargetMachine &TM); + }; + + +} // namespace llvm + +#endif diff --git a/lib/Target/Alpha/AlphaTargetAsmInfo.cpp b/lib/Target/Alpha/AlphaTargetAsmInfo.cpp new file mode 100644 index 00000000000..fd77b87f2d9 --- /dev/null +++ b/lib/Target/Alpha/AlphaTargetAsmInfo.cpp @@ -0,0 +1,21 @@ +//===-- AlphaTargetAsmInfo.cpp - Alpha asm properties -----------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by James M. Laskey and is distributed under the +// University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This file contains the declarations of the AlphaTargetAsmInfo properties. +// +//===----------------------------------------------------------------------===// + +#include "AlphaTargetAsmInfo.h" + +using namespace llvm; + +AlphaTargetAsmInfo::AlphaTargetAsmInfo(const AlphaTargetMachine &TM) { + AlignmentIsInBytes = false; + PrivateGlobalPrefix = "$"; +} diff --git a/lib/Target/Alpha/AlphaTargetAsmInfo.h b/lib/Target/Alpha/AlphaTargetAsmInfo.h new file mode 100644 index 00000000000..c8b4fd5c359 --- /dev/null +++ b/lib/Target/Alpha/AlphaTargetAsmInfo.h @@ -0,0 +1,30 @@ +//=====-- AlphaTargetAsmInfo.h - Alpha asm properties ---------*- C++ -*--====// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by James M. Laskey and is distributed under the +// University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This file contains the declaration of the AlphaTargetAsmInfo class. +// +//===----------------------------------------------------------------------===// + +#ifndef ALPHATARGETASMINFO_H +#define ALPHATARGETASMINFO_H + +#include "llvm/Target/TargetAsmInfo.h" + +namespace llvm { + + // Forward declaration. + class AlphaTargetMachine; + + struct AlphaTargetAsmInfo : public TargetAsmInfo { + AlphaTargetAsmInfo(const AlphaTargetMachine &TM); + }; + +} // namespace llvm + +#endif diff --git a/lib/Target/IA64/IA64TargetAsmInfo.cpp b/lib/Target/IA64/IA64TargetAsmInfo.cpp new file mode 100644 index 00000000000..1a7e2b2b890 --- /dev/null +++ b/lib/Target/IA64/IA64TargetAsmInfo.cpp @@ -0,0 +1,34 @@ +//===-- IA64TargetAsmInfo.cpp - IA64 asm properties -------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by James M. Laskey and is distributed under the +// University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This file contains the declarations of the IA64TargetAsmInfo properties. +// +//===----------------------------------------------------------------------===// + +#include "IA64TargetAsmInfo.h" + +using namespace llvm; + +IA64TargetAsmInfo::IA64TargetAsmInfo(const IA64TargetMachine &TM) { + CommentString = "//"; + Data8bitsDirective = "\tdata1\t"; // FIXME: check that we are + Data16bitsDirective = "\tdata2.ua\t"; // disabling auto-alignment + Data32bitsDirective = "\tdata4.ua\t"; // properly + Data64bitsDirective = "\tdata8.ua\t"; + ZeroDirective = "\t.skip\t"; + AsciiDirective = "\tstring\t"; + + GlobalVarAddrPrefix=""; + GlobalVarAddrSuffix=""; + FunctionAddrPrefix="@fptr("; + FunctionAddrSuffix=")"; + + // FIXME: would be nice to have rodata (no 'w') when appropriate? + ConstantPoolSection = "\n\t.section .data, \"aw\", \"progbits\"\n"; +} diff --git a/lib/Target/IA64/IA64TargetAsmInfo.h b/lib/Target/IA64/IA64TargetAsmInfo.h new file mode 100644 index 00000000000..681253c79ec --- /dev/null +++ b/lib/Target/IA64/IA64TargetAsmInfo.h @@ -0,0 +1,31 @@ +//=====-- IA64TargetAsmInfo.h - IA64 asm properties -----------*- C++ -*--====// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by James M. Laskey and is distributed under the +// University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This file contains the declaration of the IA64TargetAsmInfo class. +// +//===----------------------------------------------------------------------===// + +#ifndef IA64TARGETASMINFO_H +#define IA64TARGETASMINFO_H + +#include "llvm/Target/TargetAsmInfo.h" + +namespace llvm { + + // Forward declaration. + class IA64TargetMachine; + + struct IA64TargetAsmInfo : public TargetAsmInfo { + IA64TargetAsmInfo(const IA64TargetMachine &TM); + }; + + +} // namespace llvm + +#endif diff --git a/lib/Target/PowerPC/PPCTargetAsmInfo.cpp b/lib/Target/PowerPC/PPCTargetAsmInfo.cpp new file mode 100644 index 00000000000..4e174273904 --- /dev/null +++ b/lib/Target/PowerPC/PPCTargetAsmInfo.cpp @@ -0,0 +1,51 @@ +//===-- PPCTargetAsmInfo.cpp - PPC asm properties ---------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by James M. Laskey and is distributed under the +// University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This file contains the declarations of the DarwinTargetAsmInfo properties. +// +//===----------------------------------------------------------------------===// + +#include "PPCTargetAsmInfo.h" +#include "PPCTargetMachine.h" + +using namespace llvm; + +DarwinTargetAsmInfo::DarwinTargetAsmInfo(const PPCTargetMachine &TM) { + bool isPPC64 = TM.getSubtargetImpl()->isPPC64(); + + CommentString = ";"; + GlobalPrefix = "_"; + PrivateGlobalPrefix = "L"; + ZeroDirective = "\t.space\t"; + SetDirective = "\t.set"; + Data64bitsDirective = isPPC64 ? ".quad\t" : 0; + AlignmentIsInBytes = false; + ConstantPoolSection = "\t.const\t"; + JumpTableDataSection = ".const"; + JumpTableTextSection = "\t.text"; + LCOMMDirective = "\t.lcomm\t"; + StaticCtorsSection = ".mod_init_func"; + StaticDtorsSection = ".mod_term_func"; + InlineAsmStart = "# InlineAsm Start"; + InlineAsmEnd = "# InlineAsm End"; + + NeedsSet = true; + AddressSize = isPPC64 ? 8 : 4; + DwarfAbbrevSection = ".section __DWARF,__debug_abbrev"; + DwarfInfoSection = ".section __DWARF,__debug_info"; + DwarfLineSection = ".section __DWARF,__debug_line"; + DwarfFrameSection = ".section __DWARF,__debug_frame"; + DwarfPubNamesSection = ".section __DWARF,__debug_pubnames"; + DwarfPubTypesSection = ".section __DWARF,__debug_pubtypes"; + DwarfStrSection = ".section __DWARF,__debug_str"; + DwarfLocSection = ".section __DWARF,__debug_loc"; + DwarfARangesSection = ".section __DWARF,__debug_aranges"; + DwarfRangesSection = ".section __DWARF,__debug_ranges"; + DwarfMacInfoSection = ".section __DWARF,__debug_macinfo"; +} diff --git a/lib/Target/PowerPC/PPCTargetAsmInfo.h b/lib/Target/PowerPC/PPCTargetAsmInfo.h new file mode 100644 index 00000000000..d3c790c5fc9 --- /dev/null +++ b/lib/Target/PowerPC/PPCTargetAsmInfo.h @@ -0,0 +1,31 @@ +//=====-- PPCTargetAsmInfo.h - PPC asm properties -------------*- C++ -*--====// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by James M. Laskey and is distributed under the +// University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This file contains the declaration of the DarwinTargetAsmInfo class. +// +//===----------------------------------------------------------------------===// + +#ifndef PPCTARGETASMINFO_H +#define PPCTARGETASMINFO_H + +#include "llvm/Target/TargetAsmInfo.h" + +namespace llvm { + + // Forward declaration. + class PPCTargetMachine; + + struct DarwinTargetAsmInfo : public TargetAsmInfo { + DarwinTargetAsmInfo(const PPCTargetMachine &TM); + }; + + +} // namespace llvm + +#endif diff --git a/lib/Target/Sparc/SparcTargetAsmInfo.cpp b/lib/Target/Sparc/SparcTargetAsmInfo.cpp new file mode 100644 index 00000000000..01f7f11ebba --- /dev/null +++ b/lib/Target/Sparc/SparcTargetAsmInfo.cpp @@ -0,0 +1,25 @@ +//===-- SparcTargetAsmInfo.cpp - Sparc asm properties -----------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by James M. Laskey and is distributed under the +// University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This file contains the declarations of the SparcTargetAsmInfo properties. +// +//===----------------------------------------------------------------------===// + +#include "SparcTargetAsmInfo.h" + +using namespace llvm; + +SparcTargetAsmInfo::SparcTargetAsmInfo(const SparcTargetMachine &TM) { + Data16bitsDirective = "\t.half\t"; + Data32bitsDirective = "\t.word\t"; + Data64bitsDirective = 0; // .xword is only supported by V9. + ZeroDirective = "\t.skip\t"; + CommentString = "!"; + ConstantPoolSection = "\t.section \".rodata\",#alloc\n"; +} diff --git a/lib/Target/Sparc/SparcTargetAsmInfo.h b/lib/Target/Sparc/SparcTargetAsmInfo.h new file mode 100644 index 00000000000..6b2dc59847c --- /dev/null +++ b/lib/Target/Sparc/SparcTargetAsmInfo.h @@ -0,0 +1,31 @@ +//=====-- SparcTargetAsmInfo.h - Sparc asm properties ---------*- C++ -*--====// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by James M. Laskey and is distributed under the +// University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This file contains the declaration of the SparcTargetAsmInfo class. +// +//===----------------------------------------------------------------------===// + +#ifndef SPARCTARGETASMINFO_H +#define SPARCTARGETASMINFO_H + +#include "llvm/Target/TargetAsmInfo.h" + +namespace llvm { + + // Forward declaration. + class SparcTargetMachine; + + struct SparcTargetAsmInfo : public TargetAsmInfo { + SparcTargetAsmInfo(const SparcTargetMachine &TM); + }; + + +} // namespace llvm + +#endif diff --git a/lib/Target/X86/X86TargetAsmInfo.cpp b/lib/Target/X86/X86TargetAsmInfo.cpp new file mode 100644 index 00000000000..b1da4ce9d5b --- /dev/null +++ b/lib/Target/X86/X86TargetAsmInfo.cpp @@ -0,0 +1,95 @@ +//===-- X86TargetAsmInfo.cpp - X86 asm properties ---------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by James M. Laskey and is distributed under the +// University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This file contains the declarations of the X86TargetAsmInfo properties. +// +//===----------------------------------------------------------------------===// + +#include "X86TargetAsmInfo.h" +#include "X86TargetMachine.h" +#include "X86Subtarget.h" + +using namespace llvm; + +X86TargetAsmInfo::X86TargetAsmInfo(const X86TargetMachine &TM) { + const X86Subtarget *Subtarget = &TM.getSubtarget(); + + //FIXME - Should to be simplified. + + switch (Subtarget->TargetType) { + case X86Subtarget::isDarwin: + AlignmentIsInBytes = false; + GlobalPrefix = "_"; + Data64bitsDirective = 0; // we can't emit a 64-bit unit + ZeroDirective = "\t.space\t"; // ".space N" emits N zeros. + PrivateGlobalPrefix = "L"; // Marker for constant pool idxs + ConstantPoolSection = "\t.const\n"; + JumpTableDataSection = "\t.const\n"; // FIXME: depends on PIC mode + FourByteConstantSection = "\t.literal4\n"; + EightByteConstantSection = "\t.literal8\n"; + LCOMMDirective = "\t.lcomm\t"; + COMMDirectiveTakesAlignment = false; + HasDotTypeDotSizeDirective = false; + StaticCtorsSection = ".mod_init_func"; + StaticDtorsSection = ".mod_term_func"; + InlineAsmStart = "# InlineAsm Start"; + InlineAsmEnd = "# InlineAsm End"; + SetDirective = "\t.set"; + + NeedsSet = true; + DwarfAbbrevSection = ".section __DWARF,__debug_abbrev,regular,debug"; + DwarfInfoSection = ".section __DWARF,__debug_info,regular,debug"; + DwarfLineSection = ".section __DWARF,__debug_line,regular,debug"; + DwarfFrameSection = ".section __DWARF,__debug_frame,regular,debug"; + DwarfPubNamesSection = ".section __DWARF,__debug_pubnames,regular,debug"; + DwarfPubTypesSection = ".section __DWARF,__debug_pubtypes,regular,debug"; + DwarfStrSection = ".section __DWARF,__debug_str,regular,debug"; + DwarfLocSection = ".section __DWARF,__debug_loc,regular,debug"; + DwarfARangesSection = ".section __DWARF,__debug_aranges,regular,debug"; + DwarfRangesSection = ".section __DWARF,__debug_ranges,regular,debug"; + DwarfMacInfoSection = ".section __DWARF,__debug_macinfo,regular,debug"; + break; + case X86Subtarget::isCygwin: + GlobalPrefix = "_"; + COMMDirectiveTakesAlignment = false; + HasDotTypeDotSizeDirective = false; + StaticCtorsSection = "\t.section .ctors,\"aw\""; + StaticDtorsSection = "\t.section .dtors,\"aw\""; + break; + case X86Subtarget::isWindows: + GlobalPrefix = "_"; + HasDotTypeDotSizeDirective = false; + break; + default: break; + } + + if (Subtarget->isFlavorIntel()) { + GlobalPrefix = "_"; + CommentString = ";"; + + PrivateGlobalPrefix = "$"; + AlignDirective = "\talign\t"; + ZeroDirective = "\tdb\t"; + ZeroDirectiveSuffix = " dup(0)"; + AsciiDirective = "\tdb\t"; + AscizDirective = 0; + Data8bitsDirective = "\tdb\t"; + Data16bitsDirective = "\tdw\t"; + Data32bitsDirective = "\tdd\t"; + Data64bitsDirective = "\tdq\t"; + HasDotTypeDotSizeDirective = false; + + TextSection = "_text"; + DataSection = "_data"; + SwitchToSectionDirective = ""; + TextSectionStartSuffix = "\tsegment 'CODE'"; + DataSectionStartSuffix = "\tsegment 'DATA'"; + SectionEndDirectiveSuffix = "\tends\n"; + } +} diff --git a/lib/Target/X86/X86TargetAsmInfo.h b/lib/Target/X86/X86TargetAsmInfo.h new file mode 100644 index 00000000000..a5401da602b --- /dev/null +++ b/lib/Target/X86/X86TargetAsmInfo.h @@ -0,0 +1,31 @@ +//=====-- X86TargetAsmInfo.h - X86 asm properties -------------*- C++ -*--====// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by James M. Laskey and is distributed under the +// University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This file contains the declaration of the X86TargetAsmInfo class. +// +//===----------------------------------------------------------------------===// + +#ifndef X86TARGETASMINFO_H +#define X86TARGETASMINFO_H + +#include "llvm/Target/TargetAsmInfo.h" + +namespace llvm { + + // Forward declaration. + class X86TargetMachine; + + struct X86TargetAsmInfo : public TargetAsmInfo { + X86TargetAsmInfo(const X86TargetMachine &TM); + }; + + +} // namespace llvm + +#endif