├── lib ├── Target │ ├── Z80 │ │ ├── AsmParser │ │ │ ├── CMakeLists.txt │ │ │ ├── LLVMBuild.txt │ │ │ ├── Z80Operand.h │ │ │ └── Z80AsmParser.cpp │ │ ├── TargetInfo │ │ │ ├── CMakeLists.txt │ │ │ ├── LLVMBuild.txt │ │ │ └── Z80TargetInfo.cpp │ │ ├── InstPrinter │ │ │ ├── CMakeLists.txt │ │ │ ├── LLVMBuild.txt │ │ │ ├── Z80InstPrinter.cpp │ │ │ ├── EZ80InstPrinter.cpp │ │ │ ├── Z80InstPrinter.h │ │ │ ├── EZ80InstPrinter.h │ │ │ ├── Z80InstPrinterBase.h │ │ │ └── Z80InstPrinterBase.cpp │ │ ├── MCTargetDesc │ │ │ ├── CMakeLists.txt │ │ │ ├── Z80OMFObjectWriter.cpp │ │ │ ├── Z80FixupKinds.h │ │ │ ├── LLVMBuild.txt │ │ │ ├── Z80MCAsmInfo.h │ │ │ ├── Z80TargetStreamer.cpp │ │ │ ├── Z80ELFObjectWriter.cpp │ │ │ ├── Z80TargetStreamer.h │ │ │ ├── Z80MCCodeEmitter.cpp │ │ │ ├── Z80MCAsmInfo.cpp │ │ │ ├── Z80MCTargetDesc.h │ │ │ ├── Z80AsmBackend.cpp │ │ │ └── Z80MCTargetDesc.cpp │ │ ├── Z80MachineFunctionInfo.cpp │ │ ├── Z80SelectionDAGInfo.h │ │ ├── LLVMBuild.txt │ │ ├── CMakeLists.txt │ │ ├── Z80AsmPrinter.h │ │ ├── Z80CallFrameOptimization.cpp │ │ ├── Z80TargetMachine.h │ │ ├── Z80.h │ │ ├── Z80Subtarget.cpp │ │ ├── Z80MachineFunctionInfo.h │ │ ├── Z80FrameLowering.h │ │ ├── Z80CallingConv.td │ │ ├── Z80Subtarget.h │ │ ├── Z80.td │ │ ├── Z80AsmPrinter.cpp │ │ ├── Z80RegisterInfo.td │ │ ├── Z80MCInstLower.cpp │ │ ├── Z80RegisterInfo.h │ │ ├── Z80TargetMachine.cpp │ │ ├── Z80ISelDAGToDAG.cpp │ │ └── Z80ExpandPseudo.cpp │ ├── LLVMBuild.txt │ └── ARM │ │ └── LICENSE.TXT ├── Object │ ├── CMakeLists.txt │ ├── SymbolicFile.cpp │ └── Binary.cpp └── MC │ ├── OMFObjectWriter.cpp │ ├── MCAsmInfoOMF.cpp │ ├── MCSectionOMF.cpp │ ├── CMakeLists.txt │ ├── MCOMFStreamer.cpp │ └── MCAsmInfo.cpp ├── test ├── CodeGen │ ├── NVPTX │ │ └── add-128bit.ll │ ├── Hexagon │ │ └── adde.ll │ ├── MSP430 │ │ └── Inst8rr.ll │ └── X86 │ │ └── legalize-shl-vec.ll └── TableGen │ └── intrinsic-varargs.td ├── tools ├── llvm-readobj │ ├── CMakeLists.txt │ ├── OMFDumper.cpp │ └── ObjDumper.h └── clang │ ├── test │ └── SemaCXX │ │ └── deleted-operator.cpp │ ├── lib │ ├── Driver │ │ ├── CMakeLists.txt │ │ ├── ToolChains │ │ │ ├── ZDS.h │ │ │ └── ZDS.cpp │ │ └── InputInfo.h │ └── Basic │ │ ├── CMakeLists.txt │ │ └── Targets │ │ ├── Z80.cpp │ │ └── Z80.h │ ├── LICENSE.TXT │ └── include │ └── clang │ ├── module.modulemap │ └── Basic │ └── TargetBuiltins.h ├── include └── llvm │ ├── MC │ ├── MCAsmInfoOMF.h │ ├── MCOMFObjectWriter.h │ ├── MCSymbolOMF.h │ ├── MCSectionOMF.h │ ├── MCOMFStreamer.h │ └── MCDirectives.h │ ├── BinaryFormat │ └── Magic.h │ ├── CodeGen │ └── RuntimeLibcalls.h │ └── Object │ ├── OMFObjectFile.h │ └── OMF.h ├── LICENSE.TXT └── utils └── emacs └── llvm-mode.el /lib/Target/Z80/AsmParser/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_llvm_library(LLVMZ80AsmParser 2 | Z80AsmParser.cpp 3 | ) 4 | -------------------------------------------------------------------------------- /lib/Target/Z80/TargetInfo/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_llvm_library(LLVMZ80Info 2 | Z80TargetInfo.cpp 3 | ) 4 | -------------------------------------------------------------------------------- /lib/Target/Z80/InstPrinter/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_llvm_library(LLVMZ80AsmPrinter 2 | EZ80InstPrinter.cpp 3 | Z80InstPrinter.cpp 4 | Z80InstPrinterBase.cpp 5 | ) 6 | -------------------------------------------------------------------------------- /lib/Target/Z80/MCTargetDesc/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_llvm_library(LLVMZ80Desc 2 | Z80AsmBackend.cpp 3 | Z80ELFObjectWriter.cpp 4 | Z80MCCodeEmitter.cpp 5 | Z80MCTargetDesc.cpp 6 | Z80MCAsmInfo.cpp 7 | Z80OMFObjectWriter.cpp 8 | Z80TargetStreamer.cpp 9 | ) 10 | -------------------------------------------------------------------------------- /lib/Target/Z80/Z80MachineFunctionInfo.cpp: -------------------------------------------------------------------------------- 1 | //===-- Z80MachineFunctionInfo.cpp - Z80 machine function info ------------===// 2 | // 3 | // The LLVM Compiler Infrastructure 4 | // 5 | // This file is distributed under the University of Illinois Open Source 6 | // License. See LICENSE.TXT for details. 7 | // 8 | //===----------------------------------------------------------------------===// 9 | 10 | #include "Z80MachineFunctionInfo.h" 11 | 12 | using namespace llvm; 13 | 14 | void Z80MachineFunctionInfo::anchor() { } 15 | -------------------------------------------------------------------------------- /test/CodeGen/NVPTX/add-128bit.ll: -------------------------------------------------------------------------------- 1 | ; RUN: llc < %s -march=nvptx -mcpu=sm_20 | FileCheck %s 2 | 3 | target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v16:16:16-v32:32:32-v64:64:64-v128:128:128-n16:32:64" 4 | 5 | 6 | 7 | define void @foo(i64 %a, i64 %add, i128* %retptr) { 8 | ; CHECK: add.s64 9 | ; CHECK: setp.lt.u64 10 | ; CHECK: selp.u64 11 | ; CHECK: add.s64 12 | %t1 = sext i64 %a to i128 13 | %add2 = zext i64 %add to i128 14 | %val = add i128 %t1, %add2 15 | store i128 %val, i128* %retptr 16 | ret void 17 | } 18 | -------------------------------------------------------------------------------- /tools/llvm-readobj/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(LLVM_LINK_COMPONENTS 2 | DebugInfoCodeView 3 | Object 4 | BinaryFormat 5 | Support 6 | DebugInfoCodeView 7 | DebugInfoMSF 8 | DebugInfoPDB 9 | ) 10 | 11 | add_llvm_tool(llvm-readobj 12 | ARMWinEHPrinter.cpp 13 | COFFDumper.cpp 14 | COFFImportDumper.cpp 15 | ELFDumper.cpp 16 | Error.cpp 17 | llvm-readobj.cpp 18 | MachODumper.cpp 19 | ObjDumper.cpp 20 | OMFDumper.cpp 21 | WasmDumper.cpp 22 | Win64EHDumper.cpp 23 | WindowsResourceDumper.cpp 24 | ) 25 | 26 | add_llvm_tool_symlink(llvm-readelf llvm-readobj) 27 | 28 | if(LLVM_INSTALL_BINUTILS_SYMLINKS) 29 | add_llvm_tool_symlink(readelf llvm-readobj) 30 | endif() 31 | -------------------------------------------------------------------------------- /include/llvm/MC/MCAsmInfoOMF.h: -------------------------------------------------------------------------------- 1 | //===-- llvm/MC/MCAsmInfoOMF.h - OMF Asm info -------------------*- C++ -*-===// 2 | // 3 | // The LLVM Compiler Infrastructure 4 | // 5 | // This file is distributed under the University of Illinois Open Source 6 | // License. See LICENSE.TXT for details. 7 | // 8 | //===----------------------------------------------------------------------===// 9 | 10 | #ifndef LLVM_MC_MCASMINFOWASM_H 11 | #define LLVM_MC_MCASMINFOWASM_H 12 | 13 | #include "llvm/MC/MCAsmInfo.h" 14 | 15 | namespace llvm { 16 | class MCAsmInfoOMF : public MCAsmInfo { 17 | virtual void anchor(); 18 | 19 | protected: 20 | MCAsmInfoOMF(); 21 | }; 22 | } 23 | 24 | #endif // LLVM_MC_MCASMINFOWASM_H 25 | -------------------------------------------------------------------------------- /lib/Object/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_llvm_library(LLVMObject 2 | Archive.cpp 3 | ArchiveWriter.cpp 4 | Binary.cpp 5 | COFFImportFile.cpp 6 | COFFModuleDefinition.cpp 7 | COFFObjectFile.cpp 8 | Decompressor.cpp 9 | ELF.cpp 10 | ELFObjectFile.cpp 11 | Error.cpp 12 | IRObjectFile.cpp 13 | IRSymtab.cpp 14 | MachOObjectFile.cpp 15 | MachOUniversal.cpp 16 | ModuleSymbolTable.cpp 17 | Object.cpp 18 | ObjectFile.cpp 19 | OMFObjectFile.cpp 20 | RecordStreamer.cpp 21 | SymbolicFile.cpp 22 | SymbolSize.cpp 23 | WasmObjectFile.cpp 24 | WindowsResource.cpp 25 | 26 | ADDITIONAL_HEADER_DIRS 27 | ${LLVM_MAIN_INCLUDE_DIR}/llvm/Object 28 | 29 | DEPENDS 30 | intrinsics_gen 31 | llvm_vcsrevision_h 32 | ) 33 | -------------------------------------------------------------------------------- /lib/Target/Z80/MCTargetDesc/Z80OMFObjectWriter.cpp: -------------------------------------------------------------------------------- 1 | //===-- Z80OMFObjectWriter.cpp - Z80 OMF Writer ---------------------------===// 2 | // 3 | // The LLVM Compiler Infrastructure 4 | // 5 | // This file is distributed under the University of Illinois Open Source 6 | // License. See LICENSE.TXT for details. 7 | // 8 | //===----------------------------------------------------------------------===// 9 | 10 | #include "Z80MCTargetDesc.h" 11 | #include "llvm/MC/MCObjectWriter.h" 12 | #include "llvm/MC/MCOMFObjectWriter.h" 13 | #include "llvm/ADT/StringRef.h" 14 | 15 | using namespace llvm; 16 | 17 | std::unique_ptr 18 | llvm::createZ80OMFObjectWriter(raw_pwrite_stream &OS) { 19 | return createOMFObjectWriter(OS); 20 | } 21 | -------------------------------------------------------------------------------- /lib/MC/OMFObjectWriter.cpp: -------------------------------------------------------------------------------- 1 | //===- lib/MC/OMFObjectWriter.cpp - OMF File Writer -----------------------===// 2 | // 3 | // The LLVM Compiler Infrastructure 4 | // 5 | // This file is distributed under the University of Illinois Open Source 6 | // License. See LICENSE.TXT for details. 7 | // 8 | //===----------------------------------------------------------------------===// 9 | // 10 | // This file implements OMF object file writer information. 11 | // 12 | //===----------------------------------------------------------------------===// 13 | 14 | #include "llvm/MC/MCOMFObjectWriter.h" 15 | 16 | using namespace llvm; 17 | 18 | std::unique_ptr 19 | llvm::createOMFObjectWriter(raw_pwrite_stream &OS) { 20 | llvm_unreachable("Unimplemented!"); 21 | } 22 | -------------------------------------------------------------------------------- /lib/MC/MCAsmInfoOMF.cpp: -------------------------------------------------------------------------------- 1 | //===- MCAsmInfoOMF.cpp - OMF asm properties ------------------------------===// 2 | // 3 | // The LLVM Compiler Infrastructure 4 | // 5 | // This file is distributed under the University of Illinois Open Source 6 | // License. See LICENSE.TXT for details. 7 | // 8 | //===----------------------------------------------------------------------===// 9 | // 10 | // This file defines target asm properties related what form asm statements 11 | // should take in general on OMF-based targets 12 | // 13 | //===----------------------------------------------------------------------===// 14 | 15 | #include "llvm/MC/MCAsmInfoOMF.h" 16 | 17 | using namespace llvm; 18 | 19 | void MCAsmInfoOMF::anchor() {} 20 | 21 | MCAsmInfoOMF::MCAsmInfoOMF() { 22 | PrivateLabelPrefix = "L"; 23 | } 24 | -------------------------------------------------------------------------------- /lib/Target/Z80/MCTargetDesc/Z80FixupKinds.h: -------------------------------------------------------------------------------- 1 | //===-- Z80FixupKinds.h - Z80 Specific Fixup Entries ------------*- C++ -*-===// 2 | // 3 | // The LLVM Compiler Infrastructure 4 | // 5 | // This file is distributed under the University of Illinois Open Source 6 | // License. See LICENSE.TXT for details. 7 | // 8 | //===----------------------------------------------------------------------===// 9 | 10 | #ifndef LLVM_LIB_TARGET_Z80_MCTARGETDESC_Z80FIXUPKINDS_H 11 | #define LLVM_LIB_TARGET_Z80_MCTARGETDESC_Z80FIXUPKINDS_H 12 | 13 | #include "llvm/MC/MCFixup.h" 14 | 15 | namespace llvm { 16 | namespace Z80 { 17 | enum Fixups { 18 | // Marker 19 | LastTargetFixupKind = FirstTargetFixupKind, 20 | NumTargetFixupKinds = LastTargetFixupKind - FirstTargetFixupKind 21 | }; 22 | } 23 | } 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /lib/Target/Z80/TargetInfo/LLVMBuild.txt: -------------------------------------------------------------------------------- 1 | ;===- ./lib/Target/Z80/TargetInfo/LLVMBuild.txt ----------------*- Conf -*--===; 2 | ; 3 | ; The LLVM Compiler Infrastructure 4 | ; 5 | ; This file is distributed under the University of Illinois Open Source 6 | ; License. See LICENSE.TXT for details. 7 | ; 8 | ;===------------------------------------------------------------------------===; 9 | ; 10 | ; This is an LLVMBuild description file for the components in this subdirectory. 11 | ; 12 | ; For more information on the LLVMBuild system, please see: 13 | ; 14 | ; http://llvm.org/docs/LLVMBuild.html 15 | ; 16 | ;===------------------------------------------------------------------------===; 17 | 18 | [component_0] 19 | type = Library 20 | name = Z80Info 21 | parent = Z80 22 | required_libraries = Support 23 | add_to_library_groups = Z80 24 | -------------------------------------------------------------------------------- /lib/Target/Z80/InstPrinter/LLVMBuild.txt: -------------------------------------------------------------------------------- 1 | ;===- ./lib/Target/Z80/InstPrinter/LLVMBuild.txt ---------------*- Conf -*--===; 2 | ; 3 | ; The LLVM Compiler Infrastructure 4 | ; 5 | ; This file is distributed under the University of Illinois Open Source 6 | ; License. See LICENSE.TXT for details. 7 | ; 8 | ;===------------------------------------------------------------------------===; 9 | ; 10 | ; This is an LLVMBuild description file for the components in this subdirectory. 11 | ; 12 | ; For more information on the LLVMBuild system, please see: 13 | ; 14 | ; http://llvm.org/docs/LLVMBuild.html 15 | ; 16 | ;===------------------------------------------------------------------------===; 17 | 18 | [component_0] 19 | type = Library 20 | name = Z80AsmPrinter 21 | parent = Z80 22 | required_libraries = MC Support 23 | add_to_library_groups = Z80 24 | -------------------------------------------------------------------------------- /lib/Target/Z80/MCTargetDesc/LLVMBuild.txt: -------------------------------------------------------------------------------- 1 | ;===- ./lib/Target/Z80/MCTargetDesc/LLVMBuild.txt --------------*- Conf -*--===; 2 | ; 3 | ; The LLVM Compiler Infrastructure 4 | ; 5 | ; This file is distributed under the University of Illinois Open Source 6 | ; License. See LICENSE.TXT for details. 7 | ; 8 | ;===------------------------------------------------------------------------===; 9 | ; 10 | ; This is an LLVMBuild description file for the components in this subdirectory. 11 | ; 12 | ; For more information on the LLVMBuild system, please see: 13 | ; 14 | ; http://llvm.org/docs/LLVMBuild.html 15 | ; 16 | ;===------------------------------------------------------------------------===; 17 | 18 | [component_0] 19 | type = Library 20 | name = Z80Desc 21 | parent = Z80 22 | required_libraries = MC Support Z80AsmPrinter Z80Info 23 | add_to_library_groups = Z80 24 | -------------------------------------------------------------------------------- /lib/Target/Z80/AsmParser/LLVMBuild.txt: -------------------------------------------------------------------------------- 1 | ;===- ./lib/Target/Z80/AsmParser/LLVMBuild.txt -----------------*- Conf -*--===; 2 | ; 3 | ; The LLVM Compiler Infrastructure 4 | ; 5 | ; This file is distributed under the University of Illinois Open Source 6 | ; License. See LICENSE.TXT for details. 7 | ; 8 | ;===------------------------------------------------------------------------===; 9 | ; 10 | ; This is an LLVMBuild description file for the components in this subdirectory. 11 | ; 12 | ; For more information on the LLVMBuild system, please see: 13 | ; 14 | ; http://llvm.org/docs/LLVMBuild.html 15 | ; 16 | ;===------------------------------------------------------------------------===; 17 | 18 | [component_0] 19 | type = Library 20 | name = Z80AsmParser 21 | parent = Z80 22 | required_libraries = MC MCParser Support Z80Desc Z80Info 23 | add_to_library_groups = Z80 24 | -------------------------------------------------------------------------------- /lib/Target/Z80/InstPrinter/Z80InstPrinter.cpp: -------------------------------------------------------------------------------- 1 | //===- Z80InstPrinter.cpp - Convert Z80 MCInst to assembly ------*- C++ -*-===// 2 | // 3 | // The LLVM Compiler Infrastructure 4 | // 5 | // This file is distributed under the University of Illinois Open Source 6 | // License. See LICENSE.TXT for details. 7 | // 8 | //===----------------------------------------------------------------------===// 9 | // 10 | // This class prints a Z80 MCInst to a .s file. 11 | // 12 | //===----------------------------------------------------------------------===// 13 | 14 | #include "Z80InstPrinter.h" 15 | #include "llvm/MC/MCInst.h" 16 | #include "llvm/Support/ErrorHandling.h" 17 | #include "llvm/Support/FormattedStream.h" 18 | using namespace llvm; 19 | 20 | #define DEBUG_TYPE "asm-printer" 21 | 22 | // Include the auto-generated portion of the assembly writer. 23 | #include "Z80GenAsmWriter.inc" 24 | -------------------------------------------------------------------------------- /lib/Target/Z80/InstPrinter/EZ80InstPrinter.cpp: -------------------------------------------------------------------------------- 1 | //===- EZ80InstPrinter.cpp - Convert EZ80 MCInst to assembly ----*- C++ -*-===// 2 | // 3 | // The LLVM Compiler Infrastructure 4 | // 5 | // This file is distributed under the University of Illinois Open Source 6 | // License. See LICENSE.TXT for details. 7 | // 8 | //===----------------------------------------------------------------------===// 9 | // 10 | // This class prints an EZ80 MCInst to a .s file. 11 | // 12 | //===----------------------------------------------------------------------===// 13 | 14 | #include "EZ80InstPrinter.h" 15 | #include "llvm/MC/MCInst.h" 16 | #include "llvm/Support/ErrorHandling.h" 17 | #include "llvm/Support/FormattedStream.h" 18 | using namespace llvm; 19 | 20 | #define DEBUG_TYPE "asm-printer" 21 | 22 | // Include the auto-generated portion of the assembly writer. 23 | #include "EZ80GenAsmWriter.inc" 24 | -------------------------------------------------------------------------------- /include/llvm/MC/MCOMFObjectWriter.h: -------------------------------------------------------------------------------- 1 | //===- llvm/MC/MCOMFObjectWriter.h - OMF Object Writer ----------*- C++ -*-===// 2 | // 3 | // The LLVM Compiler Infrastructure 4 | // 5 | // This file is distributed under the University of Illinois Open Source 6 | // License. See LICENSE.TXT for details. 7 | // 8 | //===----------------------------------------------------------------------===// 9 | 10 | #ifndef LLVM_MC_MCOMFOBJECTWRITER_H 11 | #define LLVM_MC_MCOMFOBJECTWRITER_H 12 | 13 | #include "llvm/Support/raw_ostream.h" 14 | 15 | namespace llvm { 16 | 17 | class MCObjectWriter; 18 | 19 | /// \brief Construct a new OMF writer instance. 20 | /// 21 | /// \param OS - The stream to write to. 22 | /// \returns The constructed object writer. 23 | std::unique_ptr createOMFObjectWriter(raw_pwrite_stream &OS); 24 | 25 | } // end namespace llvm 26 | 27 | #endif // LLVM_MC_MCOMFOBJECTWRITER_H 28 | -------------------------------------------------------------------------------- /test/TableGen/intrinsic-varargs.td: -------------------------------------------------------------------------------- 1 | // RUN: llvm-tblgen -gen-intrinsic %s | FileCheck %s 2 | // XFAIL: vg_leak 3 | 4 | class IntrinsicProperty; 5 | 6 | class ValueType { 7 | string Namespace = "MVT"; 8 | int Size = size; 9 | int Value = value; 10 | } 11 | 12 | class LLVMType { 13 | ValueType VT = vt; 14 | } 15 | 16 | class Intrinsic param_types = []> { 17 | string LLVMName = name; 18 | bit isTarget = 0; 19 | string TargetPrefix = ""; 20 | list RetTypes = []; 21 | list ParamTypes = param_types; 22 | list IntrProperties = []; 23 | } 24 | 25 | // isVoid needs to match the definition in ValueTypes.td 26 | def isVoid : ValueType<0, 113>; // Produces no value 27 | def llvm_vararg_ty : LLVMType; // this means vararg here 28 | 29 | // CHECK: /* 0 */ 0, 29, 0, 30 | def int_foo : Intrinsic<"llvm.foo", [llvm_vararg_ty]>; 31 | -------------------------------------------------------------------------------- /tools/clang/test/SemaCXX/deleted-operator.cpp: -------------------------------------------------------------------------------- 1 | // RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s 2 | 3 | struct PR10757 { 4 | bool operator~() = delete; // expected-note {{explicitly deleted}} 5 | bool operator==(const PR10757&) = delete; // expected-note {{explicitly deleted}} 6 | operator float(); 7 | }; 8 | int PR10757f() { 9 | PR10757 a1; 10 | // FIXME: We get a ridiculous number of "built-in candidate" notes here... 11 | if(~a1) {} // expected-error {{overload resolution selected deleted operator}} expected-note 6-10 {{built-in candidate}} 12 | if(a1==a1) {} // expected-error {{overload resolution selected deleted operator}} expected-note 1-196 {{built-in candidate}} 13 | } 14 | 15 | struct DelOpDel { 16 | // FIXME: In MS ABI, we error twice below. 17 | virtual ~DelOpDel() {} // expected-error 1-2 {{attempt to use a deleted function}} 18 | void operator delete(void*) = delete; // expected-note 1-2 {{deleted here}} 19 | }; 20 | -------------------------------------------------------------------------------- /lib/Target/Z80/Z80SelectionDAGInfo.h: -------------------------------------------------------------------------------- 1 | //===-- Z80SelectionDAGInfo.h - Z80 SelectionDAG Info -----------*- C++ -*-===// 2 | // 3 | // The LLVM Compiler Infrastructure 4 | // 5 | // This file is distributed under the University of Illinois Open Source 6 | // License. See LICENSE.TXT for details. 7 | // 8 | //===----------------------------------------------------------------------===// 9 | // 10 | // This file defines the Z80 subclass for SelectionDAGTargetInfo. 11 | // 12 | //===----------------------------------------------------------------------===// 13 | 14 | #ifndef LLVM_LIB_TARGET_Z80_Z80SELECTIONDAGINFO_H 15 | #define LLVM_LIB_TARGET_Z80_Z80SELECTIONDAGINFO_H 16 | 17 | #include "llvm/CodeGen/SelectionDAGTargetInfo.h" 18 | 19 | namespace llvm { 20 | 21 | class Z80SelectionDAGInfo : public SelectionDAGTargetInfo { 22 | public: 23 | explicit Z80SelectionDAGInfo() = default; 24 | }; 25 | 26 | } 27 | 28 | #endif // LLVM_LIB_TARGET_Z80_Z80SELECTIONDAGINFO_H 29 | -------------------------------------------------------------------------------- /test/CodeGen/Hexagon/adde.ll: -------------------------------------------------------------------------------- 1 | ; RUN: llc -march=hexagon -hexagon-expand-condsets=0 < %s | FileCheck %s 2 | 3 | ; CHECK-DAG: r{{[0-9]+:[0-9]+}} = add(r{{[0-9]+:[0-9]+}},r{{[0-9]+:[0-9]+}}) 4 | ; CHECK-DAG: r{{[0-9]+:[0-9]+}} = add(r{{[0-9]+:[0-9]+}},r{{[0-9]+:[0-9]+}}) 5 | ; CHECK-DAG: p{{[0-9]+}} = cmp.gtu(r{{[0-9]+:[0-9]+}},r{{[0-9]+:[0-9]+}}) 6 | ; CHECK-DAG: r{{[0-9]+}} = mux(p{{[0-9]+}},r{{[0-9]+}},r{{[0-9]+}}) 7 | 8 | define void @check_adde_addc(i64 %a0, i64 %a1, i64 %a2, i64 %a3, i64* %a4, i64* %a5) { 9 | b6: 10 | %v7 = zext i64 %a0 to i128 11 | %v8 = zext i64 %a1 to i128 12 | %v9 = shl i128 %v8, 64 13 | %v10 = or i128 %v7, %v9 14 | %v11 = zext i64 %a2 to i128 15 | %v12 = zext i64 %a3 to i128 16 | %v13 = shl i128 %v12, 64 17 | %v14 = or i128 %v11, %v13 18 | %v15 = add i128 %v10, %v14 19 | %v16 = lshr i128 %v15, 64 20 | %v17 = trunc i128 %v15 to i64 21 | %v18 = trunc i128 %v16 to i64 22 | store i64 %v17, i64* %a4 23 | store i64 %v18, i64* %a5 24 | ret void 25 | } 26 | -------------------------------------------------------------------------------- /lib/Target/Z80/AsmParser/Z80Operand.h: -------------------------------------------------------------------------------- 1 | //===--- Z80Operand.h - Parsed Z80 machine instruction --------------------===// 2 | // 3 | // The LLVM Compiler Infrastructure 4 | // 5 | // This file is distributed under the University of Illinois Open Source 6 | // License. See LICENSE.TXT for details. 7 | // 8 | //===----------------------------------------------------------------------===// 9 | 10 | #ifndef LLVM_LIB_TARGET_Z80_ASMPARSER_Z80OPERAND_H 11 | #define LLVM_LIB_TARGET_Z80_ASMPARSER_Z80OPERAND_H 12 | 13 | #include "llvm/MC/MCInst.h" 14 | #include "llvm/MC/MCParser/MCParsedAsmOperand.h" 15 | #include "llvm/Support/Error.h" 16 | 17 | namespace llvm { 18 | 19 | /// Z80Operand - Instances of this class represent a parsed Z80 machine operand. 20 | struct Z80Operand : public MCParsedAsmOperand { 21 | StringRef getToken() const { 22 | llvm_unreachable("Unimplemented"); 23 | } 24 | void addRegOperands(MCInst &Inst, unsigned N) const { 25 | llvm_unreachable("Unimplemented"); 26 | } 27 | }; 28 | 29 | } 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /lib/Target/Z80/MCTargetDesc/Z80MCAsmInfo.h: -------------------------------------------------------------------------------- 1 | //===-- Z80MCAsmInfo.h - Z80 asm properties --------------------*- C++ -*--===// 2 | // 3 | // The LLVM Compiler Infrastructure 4 | // 5 | // This file is distributed under the University of Illinois Open Source 6 | // License. See LICENSE.TXT for details. 7 | // 8 | //===----------------------------------------------------------------------===// 9 | // 10 | // This file contains the declaration of the Z80MCAsmInfo class. 11 | // 12 | //===----------------------------------------------------------------------===// 13 | 14 | #ifndef LLVM_LIB_TARGET_Z80_MCTARGETDESC_Z80MCASMINFO_H 15 | #define LLVM_LIB_TARGET_Z80_MCTARGETDESC_Z80MCASMINFO_H 16 | 17 | #include "llvm/MC/MCAsmInfoOMF.h" 18 | 19 | namespace llvm { 20 | class Triple; 21 | 22 | class Z80MCAsmInfo : public MCAsmInfoOMF { 23 | void anchor() override; 24 | 25 | public: 26 | explicit Z80MCAsmInfo(const Triple &Triple); 27 | 28 | const char *getBlockDirective(int64_t Size) const override; 29 | }; 30 | } // End llvm namespace 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /lib/Target/Z80/TargetInfo/Z80TargetInfo.cpp: -------------------------------------------------------------------------------- 1 | //===-- Z80TargetInfo.cpp - Z80 Target Implementation ---------------------===// 2 | // 3 | // The LLVM Compiler Infrastructure 4 | // 5 | // This file is distributed under the University of Illinois Open Source 6 | // License. See LICENSE.TXT for details. 7 | // 8 | //===----------------------------------------------------------------------===// 9 | 10 | #include "MCTargetDesc/Z80MCTargetDesc.h" 11 | #include "llvm/Support/TargetRegistry.h" 12 | using namespace llvm; 13 | 14 | Target &llvm::getTheZ80Target() { 15 | static Target TheZ80Target; 16 | return TheZ80Target; 17 | } 18 | Target &llvm::getTheEZ80Target() { 19 | static Target TheEZ80Target; 20 | return TheEZ80Target; 21 | } 22 | 23 | extern "C" void LLVMInitializeZ80TargetInfo() { 24 | RegisterTarget X(getTheZ80Target(), "z80", 25 | "Z80 [experimental]", "Z80"); 26 | RegisterTarget Y(getTheEZ80Target(), "ez80", 27 | "eZ80 [experimental]", "Z80"); 28 | } 29 | 30 | -------------------------------------------------------------------------------- /test/CodeGen/MSP430/Inst8rr.ll: -------------------------------------------------------------------------------- 1 | ; RUN: llc -march=msp430 < %s | FileCheck %s 2 | target datalayout = "e-p:16:8:8-i8:8:8-i8:8:8-i32:8:8" 3 | target triple = "msp430-generic-generic" 4 | 5 | define i8 @mov(i8 %a, i8 %b) nounwind { 6 | ; CHECK-LABEL: mov: 7 | ; CHECK: mov.{{[bw]}} r13, r12 8 | ret i8 %b 9 | } 10 | 11 | define i8 @add(i8 %a, i8 %b) nounwind { 12 | ; CHECK-LABEL: add: 13 | ; CHECK: add.{{[bw]}} 14 | %1 = add i8 %a, %b 15 | ret i8 %1 16 | } 17 | 18 | define i8 @and(i8 %a, i8 %b) nounwind { 19 | ; CHECK-LABEL: and: 20 | ; CHECK: and.{{[bw]}} r13, r12 21 | %1 = and i8 %a, %b 22 | ret i8 %1 23 | } 24 | 25 | define i8 @bis(i8 %a, i8 %b) nounwind { 26 | ; CHECK-LABEL: bis: 27 | ; CHECK: bis.{{[bw]}} r13, r12 28 | %1 = or i8 %a, %b 29 | ret i8 %1 30 | } 31 | 32 | define i8 @bic(i8 %a, i8 %b) nounwind { 33 | ; CHECK-LABEL: bic: 34 | ; CHECK: bic.{{[bw]}} r13, r12 35 | %1 = xor i8 %b, -1 36 | %2 = and i8 %a, %1 37 | ret i8 %2 38 | } 39 | 40 | define i8 @xor(i8 %a, i8 %b) nounwind { 41 | ; CHECK-LABEL: xor: 42 | ; CHECK: xor.{{[bw]}} r13, r12 43 | %1 = xor i8 %a, %b 44 | ret i8 %1 45 | } 46 | 47 | -------------------------------------------------------------------------------- /lib/MC/MCSectionOMF.cpp: -------------------------------------------------------------------------------- 1 | //===- lib/MC/MCSectionOMF.cpp - OMF Code Section Representation ----------===// 2 | // 3 | // The LLVM Compiler Infrastructure 4 | // 5 | // This file is distributed under the University of Illinois Open Source 6 | // License. See LICENSE.TXT for details. 7 | // 8 | //===----------------------------------------------------------------------===// 9 | 10 | #include "llvm/MC/MCSectionOMF.h" 11 | #include "llvm/MC/MCAsmInfo.h" 12 | #include "llvm/ADT/Twine.h" 13 | #include "llvm/Support/raw_ostream.h" 14 | 15 | using namespace llvm; 16 | 17 | MCSectionOMF::MCSectionOMF(const Twine &Section, SectionKind K, MCSymbol *Begin) 18 | : MCSection(SV_OMF, K, Begin) { 19 | Section.toVector(SectionName); 20 | } 21 | 22 | MCSectionOMF::~MCSectionOMF() {} // anchor. 23 | 24 | void MCSectionOMF::PrintSwitchToSection(const MCAsmInfo &MAI, const Triple &T, 25 | raw_ostream &OS, 26 | const MCExpr *Subsection) const { 27 | assert(!Subsection && "Unimplemented!"); 28 | OS << "\tSEGMENT\t" << getSectionName() << '\n'; 29 | } 30 | -------------------------------------------------------------------------------- /lib/Target/Z80/LLVMBuild.txt: -------------------------------------------------------------------------------- 1 | ;===- ./lib/Target/Z80/LLVMBuild.txt ---------------------------*- Conf -*--===; 2 | ; 3 | ; The LLVM Compiler Infrastructure 4 | ; 5 | ; This file is distributed under the University of Illinois Open Source 6 | ; License. See LICENSE.TXT for details. 7 | ; 8 | ;===------------------------------------------------------------------------===; 9 | ; 10 | ; This is an LLVMBuild description file for the components in this subdirectory. 11 | ; 12 | ; For more information on the LLVMBuild system, please see: 13 | ; 14 | ; http://llvm.org/docs/LLVMBuild.html 15 | ; 16 | ;===------------------------------------------------------------------------===; 17 | 18 | [common] 19 | subdirectories = AsmParser InstPrinter MCTargetDesc TargetInfo 20 | 21 | [component_0] 22 | type = TargetGroup 23 | name = Z80 24 | parent = Target 25 | has_asmparser = 1 26 | has_asmprinter = 1 27 | 28 | [component_1] 29 | type = Library 30 | name = Z80CodeGen 31 | parent = Z80 32 | required_libraries = AsmPrinter CodeGen Core MC SelectionDAG Support Target TransformUtils Z80AsmPrinter Z80Desc Z80Info 33 | add_to_library_groups = Z80 34 | -------------------------------------------------------------------------------- /lib/Target/Z80/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(LLVM_TARGET_DEFINITIONS Z80.td) 2 | 3 | tablegen(LLVM Z80GenRegisterInfo.inc -gen-register-info) 4 | tablegen(LLVM Z80GenInstrInfo.inc -gen-instr-info) 5 | tablegen(LLVM Z80GenAsmWriter.inc -gen-asm-writer) 6 | tablegen(LLVM EZ80GenAsmWriter.inc -gen-asm-writer -asmwriternum=1) 7 | tablegen(LLVM Z80GenAsmMatcher.inc -gen-asm-matcher) 8 | tablegen(LLVM Z80GenDAGISel.inc -gen-dag-isel) 9 | tablegen(LLVM Z80GenCallingConv.inc -gen-callingconv) 10 | tablegen(LLVM Z80GenSubtargetInfo.inc -gen-subtarget) 11 | add_public_tablegen_target(Z80CommonTableGen) 12 | 13 | set(sources 14 | Z80AsmPrinter.cpp 15 | Z80CallFrameOptimization.cpp 16 | Z80ExpandPseudo.cpp 17 | Z80FrameLowering.cpp 18 | Z80ISelDAGToDAG.cpp 19 | Z80ISelLowering.cpp 20 | Z80InstrInfo.cpp 21 | Z80MachineFunctionInfo.cpp 22 | Z80MachineLateOptimization.cpp 23 | Z80MCInstLower.cpp 24 | Z80RegisterInfo.cpp 25 | Z80Subtarget.cpp 26 | Z80TargetMachine.cpp 27 | ) 28 | 29 | add_llvm_target(Z80CodeGen ${sources}) 30 | 31 | add_subdirectory(AsmParser) 32 | add_subdirectory(InstPrinter) 33 | add_subdirectory(MCTargetDesc) 34 | add_subdirectory(TargetInfo) 35 | -------------------------------------------------------------------------------- /include/llvm/MC/MCSymbolOMF.h: -------------------------------------------------------------------------------- 1 | //===- MCSymbolOMF.h - -----------------------------------------*- C++ -*-===// 2 | // 3 | // The LLVM Compiler Infrastructure 4 | // 5 | // This file is distributed under the University of Illinois Open Source 6 | // License. See LICENSE.TXT for details. 7 | // 8 | //===----------------------------------------------------------------------===// 9 | #ifndef LLVM_MC_MCSYMBOLOMF_H 10 | #define LLVM_MC_MCSYMBOLOMF_H 11 | 12 | #include "llvm/MC/MCSymbol.h" 13 | 14 | namespace llvm { 15 | class MCSymbolOMF : public MCSymbol { 16 | /// An expression describing how to calculate the size of a symbol. If a 17 | /// symbol has no size this field will be NULL. 18 | const MCExpr *SymbolSize = nullptr; 19 | 20 | public: 21 | MCSymbolOMF(const StringMapEntry *Name, bool isTemporary) 22 | : MCSymbol(SymbolKindELF, Name, isTemporary) {} 23 | void setSize(const MCExpr *SS) { SymbolSize = SS; } 24 | 25 | const MCExpr *getSize() const { return SymbolSize; } 26 | 27 | static bool classof(const MCSymbol *S) { return S->isOMF(); } 28 | 29 | private: 30 | void setIsBindingSet() const; 31 | }; 32 | } 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /lib/Target/Z80/InstPrinter/Z80InstPrinter.h: -------------------------------------------------------------------------------- 1 | //===- Z80InstPrinter.h - Convert Z80 MCInst to assembly --------*- C++ -*-===// 2 | // 3 | // The LLVM Compiler Infrastructure 4 | // 5 | // This file is distributed under the University of Illinois Open Source 6 | // License. See LICENSE.TXT for details. 7 | // 8 | //===----------------------------------------------------------------------===// 9 | // 10 | // This class prints a Z80 MCInst to a .s file. 11 | // 12 | //===----------------------------------------------------------------------===// 13 | 14 | #ifndef LLVM_LIB_TARGET_Z80_INSTPRINTER_Z80INSTPRINTER_H 15 | #define LLVM_LIB_TARGET_Z80_INSTPRINTER_Z80INSTPRINTER_H 16 | 17 | #include "Z80InstPrinterBase.h" 18 | 19 | namespace llvm { 20 | class Z80InstPrinter final : public Z80InstPrinterBase { 21 | public: 22 | Z80InstPrinter(const MCAsmInfo &MAI, const MCInstrInfo &MII, 23 | const MCRegisterInfo &MRI) 24 | : Z80InstPrinterBase(MAI, MII, MRI) {} 25 | 26 | // Autogenerated by tblgen. 27 | void printInstruction(const MCInst *MI, raw_ostream &OS) override; 28 | StringRef getRegName(unsigned RegNo) const override { 29 | return getRegisterName(RegNo); 30 | } 31 | static const char *getRegisterName(unsigned RegNo); 32 | }; 33 | } 34 | 35 | #endif 36 | -------------------------------------------------------------------------------- /lib/Target/Z80/InstPrinter/EZ80InstPrinter.h: -------------------------------------------------------------------------------- 1 | //===- EZ80InstPrinter.h - Convert EZ80 MCInst to assembly ------*- C++ -*-===// 2 | // 3 | // The LLVM Compiler Infrastructure 4 | // 5 | // This file is distributed under the University of Illinois Open Source 6 | // License. See LICENSE.TXT for details. 7 | // 8 | //===----------------------------------------------------------------------===// 9 | // 10 | // This class prints an EZ80 MCInst to a .s file. 11 | // 12 | //===----------------------------------------------------------------------===// 13 | 14 | #ifndef LLVM_LIB_TARGET_Z80_INSTPRINTER_EZ80INSTPRINTER_H 15 | #define LLVM_LIB_TARGET_Z80_INSTPRINTER_EZ80INSTPRINTER_H 16 | 17 | #include "Z80InstPrinterBase.h" 18 | 19 | namespace llvm { 20 | class Z80EInstPrinter final : public Z80InstPrinterBase { 21 | public: 22 | Z80EInstPrinter(const MCAsmInfo &MAI, const MCInstrInfo &MII, 23 | const MCRegisterInfo &MRI) 24 | : Z80InstPrinterBase(MAI, MII, MRI) {} 25 | 26 | // Autogenerated by tblgen. 27 | void printInstruction(const MCInst *MI, raw_ostream &OS) override; 28 | StringRef getRegName(unsigned RegNo) const override { 29 | return getRegisterName(RegNo); 30 | } 31 | static const char *getRegisterName(unsigned RegNo); 32 | }; 33 | } 34 | 35 | #endif 36 | -------------------------------------------------------------------------------- /lib/Target/Z80/Z80AsmPrinter.h: -------------------------------------------------------------------------------- 1 | //===-- Z80AsmPrinter.h - Z80 implementation of AsmPrinter ------*- C++ -*-===// 2 | // 3 | // The LLVM Compiler Infrastructure 4 | // 5 | // This file is distributed under the University of Illinois Open Source 6 | // License. See LICENSE.TXT for details. 7 | // 8 | //===----------------------------------------------------------------------===// 9 | 10 | #ifndef LLVM_LIB_TARGET_Z80_Z80ASMPRINTER_H 11 | #define LLVM_LIB_TARGET_Z80_Z80ASMPRINTER_H 12 | 13 | #include "Z80Subtarget.h" 14 | #include "llvm/CodeGen/AsmPrinter.h" 15 | 16 | namespace llvm { 17 | 18 | class LLVM_LIBRARY_VISIBILITY Z80AsmPrinter : public AsmPrinter { 19 | const Z80Subtarget *Subtarget; 20 | 21 | public: 22 | explicit Z80AsmPrinter(TargetMachine &TM, 23 | std::unique_ptr Streamer) 24 | : AsmPrinter(TM, std::move(Streamer)) {} 25 | 26 | StringRef getPassName() const override { 27 | return "Z80 Assembly / Object Emitter"; 28 | } 29 | 30 | const Z80Subtarget &getSubtarget() const { return *Subtarget; } 31 | 32 | void EmitStartOfAsmFile(Module &M) override; 33 | void emitInlineAsmEnd(const MCSubtargetInfo &StartInfo, 34 | const MCSubtargetInfo *EndInfo) const override; 35 | void EmitEndOfAsmFile(Module &M) override; 36 | void EmitGlobalVariable(const GlobalVariable *GV) override; 37 | void EmitInstruction(const MachineInstr *MI) override; 38 | }; 39 | } // End llvm namespace 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /include/llvm/MC/MCSectionOMF.h: -------------------------------------------------------------------------------- 1 | //===- MCSectionOMF.h - OMF Machine Code Sections ---------------*- C++ -*-===// 2 | // 3 | // The LLVM Compiler Infrastructure 4 | // 5 | // This file is distributed under the University of Illinois Open Source 6 | // License. See LICENSE.TXT for details. 7 | // 8 | //===----------------------------------------------------------------------===// 9 | // 10 | // This file declares the MCSectionWasm class. 11 | // 12 | //===----------------------------------------------------------------------===// 13 | 14 | #ifndef LLVM_MC_MCSECTIONOMF_H 15 | #define LLVM_MC_MCSECTIONOMF_H 16 | 17 | #include "llvm/MC/MCSection.h" 18 | 19 | namespace llvm { 20 | 21 | class MCSectionOMF final : public MCSection { 22 | SmallString<8> SectionName; 23 | 24 | private: 25 | friend class MCContext; 26 | MCSectionOMF(const Twine &Section, SectionKind K, MCSymbol *Begin); 27 | 28 | public: 29 | ~MCSectionOMF(); 30 | 31 | StringRef getSectionName() const { return SectionName; } 32 | 33 | void PrintSwitchToSection(const MCAsmInfo &MAI, const Triple &T, 34 | raw_ostream &OS, 35 | const MCExpr *Subsection) const override; 36 | bool UseCodeAlign() const override { return getKind().isText(); } 37 | bool isVirtualSection() const override { return getKind().isBSS(); } 38 | 39 | static bool classof(const MCSection *S) { 40 | return S->getVariant() == SV_OMF; 41 | } 42 | }; 43 | 44 | } // end namespace llvm 45 | 46 | #endif 47 | -------------------------------------------------------------------------------- /lib/Target/Z80/Z80CallFrameOptimization.cpp: -------------------------------------------------------------------------------- 1 | //===----- Z80CallFrameOptimization.cpp - Optimize z80 call sequences -----===// 2 | // 3 | // The LLVM Compiler Infrastructure 4 | // 5 | // This file is distributed under the University of Illinois Open Source 6 | // License. See LICENSE.TXT for details. 7 | // 8 | //===----------------------------------------------------------------------===// 9 | // 10 | // This file defines a pass that optimizes call sequences on z80. 11 | // 12 | //===----------------------------------------------------------------------===// 13 | 14 | #include "Z80.h" 15 | #include "llvm/CodeGen/MachineFunctionPass.h" 16 | 17 | using namespace llvm; 18 | 19 | #define DEBUG_TYPE "z80-cf-opt" 20 | 21 | static cl::opt 22 | NoZ80CFOpt("no-z80-call-frame-opt", 23 | cl::desc("Avoid optimizing z80 call frames"), 24 | cl::init(false), cl::Hidden); 25 | 26 | namespace { 27 | class Z80CallFrameOptimization : public MachineFunctionPass { 28 | public: 29 | Z80CallFrameOptimization() : MachineFunctionPass(ID) {} 30 | 31 | bool runOnMachineFunction(MachineFunction &MF) override; 32 | 33 | private: 34 | static char ID; 35 | }; 36 | 37 | char Z80CallFrameOptimization::ID = 0; 38 | } // end anonymous namespace 39 | 40 | FunctionPass *llvm::createZ80CallFrameOptimization() { 41 | return new Z80CallFrameOptimization(); 42 | } 43 | 44 | bool Z80CallFrameOptimization::runOnMachineFunction(MachineFunction &MF) { 45 | if (skipFunction(*MF.getFunction()) || NoZ80CFOpt.getValue()) 46 | return false; 47 | return false; 48 | } 49 | -------------------------------------------------------------------------------- /lib/MC/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_llvm_library(LLVMMC 2 | ConstantPools.cpp 3 | ELFObjectWriter.cpp 4 | MCAsmBackend.cpp 5 | MCAsmInfo.cpp 6 | MCAsmInfoCOFF.cpp 7 | MCAsmInfoDarwin.cpp 8 | MCAsmInfoELF.cpp 9 | MCAsmInfoOMF.cpp 10 | MCAsmInfoWasm.cpp 11 | MCAsmStreamer.cpp 12 | MCAssembler.cpp 13 | MCCodeEmitter.cpp 14 | MCCodePadder.cpp 15 | MCCodeView.cpp 16 | MCContext.cpp 17 | MCDwarf.cpp 18 | MCELFObjectTargetWriter.cpp 19 | MCELFStreamer.cpp 20 | MCExpr.cpp 21 | MCFragment.cpp 22 | MCInst.cpp 23 | MCInstPrinter.cpp 24 | MCInstrAnalysis.cpp 25 | MCInstrDesc.cpp 26 | MCLabel.cpp 27 | MCLinkerOptimizationHint.cpp 28 | MCMachOStreamer.cpp 29 | MCMachObjectTargetWriter.cpp 30 | MCNullStreamer.cpp 31 | MCObjectFileInfo.cpp 32 | MCObjectStreamer.cpp 33 | MCObjectWriter.cpp 34 | MCOMFStreamer.cpp 35 | MCRegisterInfo.cpp 36 | MCSchedule.cpp 37 | MCSection.cpp 38 | MCSectionCOFF.cpp 39 | MCSectionELF.cpp 40 | MCSectionMachO.cpp 41 | MCSectionOMF.cpp 42 | MCSectionWasm.cpp 43 | MCStreamer.cpp 44 | MCSubtargetInfo.cpp 45 | MCSymbol.cpp 46 | MCSymbolELF.cpp 47 | MCTargetOptions.cpp 48 | MCValue.cpp 49 | MCWasmObjectTargetWriter.cpp 50 | MCWasmStreamer.cpp 51 | MCWin64EH.cpp 52 | MCWinCOFFStreamer.cpp 53 | MCWinEH.cpp 54 | MachObjectWriter.cpp 55 | OMFObjectWriter.cpp 56 | StringTableBuilder.cpp 57 | SubtargetFeature.cpp 58 | WasmObjectWriter.cpp 59 | WinCOFFObjectWriter.cpp 60 | 61 | ADDITIONAL_HEADER_DIRS 62 | ${LLVM_MAIN_INCLUDE_DIR}/llvm/MC 63 | ) 64 | 65 | add_subdirectory(MCParser) 66 | add_subdirectory(MCDisassembler) 67 | -------------------------------------------------------------------------------- /lib/Target/Z80/MCTargetDesc/Z80TargetStreamer.cpp: -------------------------------------------------------------------------------- 1 | //===- Z80TargetStreamer.cpp - Z80TargetStreamer class --*- C++ -*---------===// 2 | // 3 | // The LLVM Compiler Infrastructure 4 | // 5 | // This file is distributed under the University of Illinois Open Source 6 | // License. See LICENSE.TXT for details. 7 | // 8 | //===----------------------------------------------------------------------===// 9 | // 10 | // This file implements the Z80TargetStreamer class. 11 | // 12 | //===----------------------------------------------------------------------===// 13 | 14 | #include "Z80TargetStreamer.h" 15 | #include "llvm/MC/MCContext.h" 16 | #include "llvm/Support/FormattedStream.h" 17 | 18 | using namespace llvm; 19 | 20 | Z80TargetStreamer::Z80TargetStreamer(MCStreamer &S) 21 | : MCTargetStreamer(S) {} 22 | 23 | Z80TargetAsmStreamer::Z80TargetAsmStreamer(MCStreamer &S, 24 | formatted_raw_ostream &OS) 25 | : Z80TargetStreamer(S), MAI(S.getContext().getAsmInfo()), OS(OS) {} 26 | 27 | void Z80TargetAsmStreamer::emitAlign(unsigned ByteAlignment) { 28 | if (ByteAlignment > 1) 29 | OS << "\tALIGN\t" << ByteAlignment << '\n'; 30 | } 31 | 32 | void Z80TargetAsmStreamer::emitBlock(uint64_t NumBytes) { 33 | if (NumBytes) 34 | OS << "\tDS\t" << NumBytes << '\n'; 35 | } 36 | 37 | void Z80TargetAsmStreamer::emitGlobal(MCSymbol *Symbol) { 38 | OS << "\tXDEF\t"; 39 | Symbol->print(OS, MAI); 40 | OS << '\n'; 41 | } 42 | 43 | void Z80TargetAsmStreamer::emitExtern(MCSymbol *Symbol) { 44 | OS << "\tXREF\t"; 45 | Symbol->print(OS, MAI); 46 | OS << '\n'; 47 | } 48 | -------------------------------------------------------------------------------- /lib/Target/Z80/Z80TargetMachine.h: -------------------------------------------------------------------------------- 1 | //===-- Z80TargetMachine.h - Define TargetMachine for the Z80 ---*- C++ -*-===// 2 | // 3 | // The LLVM Compiler Infrastructure 4 | // 5 | // This file is distributed under the University of Illinois Open Source 6 | // License. See LICENSE.TXT for details. 7 | // 8 | //===----------------------------------------------------------------------===// 9 | // 10 | // This file declares the Sparc specific subclass of TargetMachine. 11 | // 12 | //===----------------------------------------------------------------------===// 13 | 14 | #ifndef LLVM_LIB_TARGET_Z80_Z80TARGETMACHINE_H 15 | #define LLVM_LIB_TARGET_Z80_Z80TARGETMACHINE_H 16 | 17 | #include "Z80Subtarget.h" 18 | #include "llvm/Target/TargetMachine.h" 19 | 20 | namespace llvm { 21 | 22 | class Z80TargetMachine : public LLVMTargetMachine { 23 | std::unique_ptr TLOF; 24 | mutable StringMap> SubtargetMap; 25 | 26 | public: 27 | Z80TargetMachine(const Target &T, const Triple &TT, StringRef CPU, 28 | StringRef FS, const TargetOptions &Options, 29 | Optional RM, Optional CM, 30 | CodeGenOpt::Level OL, bool JIT); 31 | ~Z80TargetMachine() override; 32 | const Z80Subtarget *getSubtargetImpl(const Function &F) const override; 33 | 34 | // Set up the pass pipeline. 35 | TargetPassConfig *createPassConfig(PassManagerBase &PM) override; 36 | TargetLoweringObjectFile *getObjFileLowering() const override { 37 | return TLOF.get(); 38 | } 39 | }; 40 | 41 | } // end namespace llvm 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /lib/Target/Z80/Z80.h: -------------------------------------------------------------------------------- 1 | //===-- Z80.h - Top-level interface for Z80 representation ------*- C++ -*-===// 2 | // 3 | // The LLVM Compiler Infrastructure 4 | // 5 | // This file is distributed under the University of Illinois Open Source 6 | // License. See LICENSE.TXT for details. 7 | // 8 | //===----------------------------------------------------------------------===// 9 | // 10 | // This file contains the entry points for global functions defined in the LLVM 11 | // Z80 back-end. 12 | // 13 | //===----------------------------------------------------------------------===// 14 | 15 | #ifndef LLVM_LIB_TARGET_Z80_Z80_H 16 | #define LLVM_LIB_TARGET_Z80_Z80_H 17 | 18 | #include "MCTargetDesc/Z80MCTargetDesc.h" 19 | #include "llvm/Support/CodeGen.h" 20 | 21 | namespace llvm { 22 | class FunctionPass; 23 | class Z80TargetMachine; 24 | 25 | /// This pass converts a legalized DAG into a Z80-specific DAG, ready for 26 | /// instruction scheduling. 27 | FunctionPass *createZ80ISelDag(Z80TargetMachine &TM, 28 | CodeGenOpt::Level OptLevel); 29 | 30 | /// Return a pass that optimizes z80 call sequences. 31 | FunctionPass *createZ80CallFrameOptimization(); 32 | 33 | /// Return a Machine IR pass that expands Z80-specific pseudo 34 | /// instructions into a sequence of actual instructions. This pass 35 | /// must run after prologue/epilogue insertion and before lowering 36 | /// the MachineInstr to MC. 37 | FunctionPass *createZ80ExpandPseudoPass(); 38 | 39 | /// Return a pass that optimizes instructions after register selection. 40 | FunctionPass *createZ80MachineLateOptimization(); 41 | } // End llvm namespace 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /lib/Target/Z80/MCTargetDesc/Z80ELFObjectWriter.cpp: -------------------------------------------------------------------------------- 1 | //===-- Z80ELFObjectWriter.cpp - Z80 ELF Writer ---------------------------===// 2 | // 3 | // The LLVM Compiler Infrastructure 4 | // 5 | // This file is distributed under the University of Illinois Open Source 6 | // License. See LICENSE.TXT for details. 7 | // 8 | //===----------------------------------------------------------------------===// 9 | 10 | #include "Z80MCTargetDesc.h" 11 | #include "llvm/MC/MCELFObjectWriter.h" 12 | #include "llvm/MC/MCObjectWriter.h" 13 | using namespace llvm; 14 | 15 | namespace { 16 | class Z80ELFObjectWriter : public MCELFObjectTargetWriter { 17 | public: 18 | Z80ELFObjectWriter(uint8_t OSABI); 19 | 20 | ~Z80ELFObjectWriter() override; 21 | 22 | protected: 23 | unsigned getRelocType(MCContext &Ctx, const MCValue &Target, 24 | const MCFixup &Fixup, bool IsPCRel) const override; 25 | }; 26 | } 27 | 28 | Z80ELFObjectWriter::Z80ELFObjectWriter(uint8_t OSABI) 29 | : MCELFObjectTargetWriter(/*IsELF64*/ false, OSABI, ELF::EM_Z80, 30 | /*HasRelocationAddend*/ false) {} 31 | 32 | Z80ELFObjectWriter::~Z80ELFObjectWriter() {} 33 | 34 | unsigned 35 | Z80ELFObjectWriter::getRelocType(MCContext &Ctx, const MCValue &Target, 36 | const MCFixup &Fixup, bool IsPCRel) const { 37 | llvm_unreachable("Unimplemented"); 38 | } 39 | 40 | std::unique_ptr 41 | llvm::createZ80ELFObjectWriter(raw_pwrite_stream &OS, uint8_t OSABI) { 42 | auto MOTW = llvm::make_unique(OSABI); 43 | return createELFObjectWriter(std::move(MOTW), OS, /*IsLittleEndian*/ true); 44 | } 45 | -------------------------------------------------------------------------------- /lib/Target/Z80/Z80Subtarget.cpp: -------------------------------------------------------------------------------- 1 | //===-- Z80Subtarget.cpp - Z80 Subtarget Information ----------------------===// 2 | // 3 | // The LLVM Compiler Infrastructure 4 | // 5 | // This file is distributed under the University of Illinois Open Source 6 | // License. See LICENSE.TXT for details. 7 | // 8 | //===----------------------------------------------------------------------===// 9 | // 10 | // This file implements the Z80 specific subclass of TargetSubtargetInfo. 11 | // 12 | //===----------------------------------------------------------------------===// 13 | 14 | #include "Z80Subtarget.h" 15 | #include "MCTargetDesc/Z80MCTargetDesc.h" 16 | #include "Z80FrameLowering.h" 17 | using namespace llvm; 18 | 19 | #define DEBUG_TYPE "z80-subtarget" 20 | 21 | #define GET_SUBTARGETINFO_TARGET_DESC 22 | #define GET_SUBTARGETINFO_CTOR 23 | #include "Z80GenSubtargetInfo.inc" 24 | 25 | Z80Subtarget &Z80Subtarget::initializeSubtargetDependencies(StringRef CPU, 26 | StringRef FS) { 27 | ParseSubtargetFeatures(CPU, FS); 28 | HasIdxHalfRegs = HasUndocOps || HasEZ80Ops; 29 | return *this; 30 | } 31 | 32 | Z80Subtarget::Z80Subtarget(const Triple &TT, const std::string &CPU, 33 | const std::string &FS, const Z80TargetMachine &TM) 34 | : Z80GenSubtargetInfo(TT, CPU, FS), TargetTriple(TT), 35 | In16BitMode(TT.isArch16Bit() || TT.getEnvironment() == Triple::CODE16), 36 | In24BitMode(!In16BitMode), HasUndocOps(false), HasZ180Ops(false), 37 | HasEZ80Ops(false), HasIdxHalfRegs(false), 38 | InstrInfo(initializeSubtargetDependencies(CPU, FS)), 39 | TLInfo(TM, *this), FrameLowering(*this) { 40 | } 41 | -------------------------------------------------------------------------------- /tools/clang/lib/Driver/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(LLVM_LINK_COMPONENTS 2 | BinaryFormat 3 | Option 4 | Support 5 | ) 6 | 7 | if(WIN32) 8 | # MSVCToolChain.cpp uses version.dll. 9 | set(system_libs version) 10 | endif() 11 | 12 | add_clang_library(clangDriver 13 | Action.cpp 14 | Compilation.cpp 15 | Distro.cpp 16 | Driver.cpp 17 | DriverOptions.cpp 18 | Job.cpp 19 | Multilib.cpp 20 | Phases.cpp 21 | SanitizerArgs.cpp 22 | Tool.cpp 23 | ToolChain.cpp 24 | ToolChains/Arch/AArch64.cpp 25 | ToolChains/Arch/ARM.cpp 26 | ToolChains/Arch/Mips.cpp 27 | ToolChains/Arch/PPC.cpp 28 | ToolChains/Arch/Sparc.cpp 29 | ToolChains/Arch/SystemZ.cpp 30 | ToolChains/Arch/X86.cpp 31 | ToolChains/Ananas.cpp 32 | ToolChains/AMDGPU.cpp 33 | ToolChains/AVR.cpp 34 | ToolChains/BareMetal.cpp 35 | ToolChains/Clang.cpp 36 | ToolChains/CloudABI.cpp 37 | ToolChains/CommonArgs.cpp 38 | ToolChains/Contiki.cpp 39 | ToolChains/CrossWindows.cpp 40 | ToolChains/Cuda.cpp 41 | ToolChains/Darwin.cpp 42 | ToolChains/DragonFly.cpp 43 | ToolChains/FreeBSD.cpp 44 | ToolChains/Fuchsia.cpp 45 | ToolChains/Gnu.cpp 46 | ToolChains/Haiku.cpp 47 | ToolChains/Hexagon.cpp 48 | ToolChains/Linux.cpp 49 | ToolChains/MipsLinux.cpp 50 | ToolChains/MinGW.cpp 51 | ToolChains/Minix.cpp 52 | ToolChains/MSVC.cpp 53 | ToolChains/Myriad.cpp 54 | ToolChains/NaCl.cpp 55 | ToolChains/NetBSD.cpp 56 | ToolChains/OpenBSD.cpp 57 | ToolChains/PS4CPU.cpp 58 | ToolChains/Solaris.cpp 59 | ToolChains/TCE.cpp 60 | ToolChains/WebAssembly.cpp 61 | ToolChains/XCore.cpp 62 | ToolChains/ZDS.cpp 63 | Types.cpp 64 | XRayArgs.cpp 65 | 66 | DEPENDS 67 | ClangDriverOptions 68 | 69 | LINK_LIBS 70 | clangBasic 71 | ${system_libs} 72 | ) 73 | -------------------------------------------------------------------------------- /lib/Target/Z80/Z80MachineFunctionInfo.h: -------------------------------------------------------------------------------- 1 | //===-- Z80MachineFunctionInfo.h - Z80 machine function info ----*- C++ -*-===// 2 | // 3 | // The LLVM Compiler Infrastructure 4 | // 5 | // This file is distributed under the University of Illinois Open Source 6 | // License. See LICENSE.TXT for details. 7 | // 8 | //===----------------------------------------------------------------------===// 9 | // 10 | // This file declares Z80-specific per-machine-function information. 11 | // 12 | //===----------------------------------------------------------------------===// 13 | 14 | #ifndef LLVM_LIB_TARGET_Z80_Z80MACHINEFUNCTIONINFO_H 15 | #define LLVM_LIB_TARGET_Z80_Z80MACHINEFUNCTIONINFO_H 16 | 17 | #include "llvm/CodeGen/MachineFunction.h" 18 | 19 | namespace llvm { 20 | 21 | /// Z80MachineFunctionInfo - This class is derived from MachineFunction and 22 | /// contains private Z80 target-specific information for each MachineFunction. 23 | class Z80MachineFunctionInfo : public MachineFunctionInfo { 24 | virtual void anchor(); 25 | 26 | /// CalleeSavedFrameSize - Size of the callee-saved register portion of the 27 | /// stack frame in bytes. 28 | unsigned CalleeSavedFrameSize = 0; 29 | 30 | /// VarArgsFrameIndex - FrameIndex for start of varargs area. 31 | int VarArgsFrameIndex = 0; 32 | 33 | public: 34 | Z80MachineFunctionInfo() = default; 35 | 36 | explicit Z80MachineFunctionInfo(MachineFunction &MF) {} 37 | 38 | unsigned getCalleeSavedFrameSize() const { return CalleeSavedFrameSize; } 39 | void setCalleeSavedFrameSize(unsigned Bytes) { CalleeSavedFrameSize = Bytes; } 40 | 41 | int getVarArgsFrameIndex() const { return VarArgsFrameIndex; } 42 | void setVarArgsFrameIndex(int Idx) { VarArgsFrameIndex = Idx; } 43 | }; 44 | 45 | } // End llvm namespace 46 | 47 | #endif 48 | -------------------------------------------------------------------------------- /lib/Target/Z80/MCTargetDesc/Z80TargetStreamer.h: -------------------------------------------------------------------------------- 1 | //==-- Z80TargetStreamer.h - Z80 Target Streamer -----------------*- C++ -*-==// 2 | // 3 | // The LLVM Compiler Infrastructure 4 | // 5 | // This file is distributed under the University of Illinois Open Source 6 | // License. See LICENSE.TXT for details. 7 | // 8 | //===----------------------------------------------------------------------===// 9 | /// 10 | /// \file 11 | /// \brief This file declares Z80-specific target streamer classes. 12 | /// These are for implementing support for target-specific assembly directives. 13 | /// 14 | //===----------------------------------------------------------------------===// 15 | 16 | #ifndef LLVM_LIB_TARGET_Z80_MCTARGETDESC_Z80TARGETSTREAMER_H 17 | #define LLVM_LIB_TARGET_Z80_MCTARGETDESC_Z80TARGETSTREAMER_H 18 | 19 | #include "llvm/MC/MCStreamer.h" 20 | 21 | namespace llvm { 22 | 23 | class Z80TargetStreamer : public MCTargetStreamer { 24 | public: 25 | explicit Z80TargetStreamer(MCStreamer &S); 26 | 27 | // .align 28 | virtual void emitAlign(unsigned ByteAlignment) = 0; 29 | 30 | // .block 31 | virtual void emitBlock(uint64_t NumBytes) = 0; 32 | 33 | // .global 34 | virtual void emitGlobal(MCSymbol *Symbol) = 0; 35 | 36 | // .extern 37 | virtual void emitExtern(MCSymbol *Symbol) = 0; 38 | }; 39 | 40 | class Z80TargetAsmStreamer final : public Z80TargetStreamer { 41 | const MCAsmInfo *MAI; 42 | formatted_raw_ostream &OS; 43 | 44 | public: 45 | Z80TargetAsmStreamer(MCStreamer &S, formatted_raw_ostream &OS); 46 | 47 | void emitAlign(unsigned ByteAlignment) override; 48 | void emitBlock(uint64_t NumBytes) override; 49 | void emitGlobal(MCSymbol *Symbol) override; 50 | void emitExtern(MCSymbol *Symbol) override; 51 | }; 52 | 53 | } // end namespace llvm 54 | 55 | #endif // LLVM_LIB_TARGET_Z80_MCTARGETDESC_Z80TARGETSTREAMER_H 56 | -------------------------------------------------------------------------------- /include/llvm/MC/MCOMFStreamer.h: -------------------------------------------------------------------------------- 1 | //===- MCOMFStreamer.h - MCStreamer OMF Object File Interface ---*- C++ -*-===// 2 | // 3 | // The LLVM Compiler Infrastructure 4 | // 5 | // This file is distributed under the University of Illinois Open Source 6 | // License. See LICENSE.TXT for details. 7 | // 8 | //===----------------------------------------------------------------------===// 9 | 10 | #ifndef LLVM_MC_MCOMFSTREAMER_H 11 | #define LLVM_MC_MCOMFSTREAMER_H 12 | 13 | #include "llvm/ADT/SmallVector.h" 14 | #include "llvm/MC/MCDirectives.h" 15 | #include "llvm/MC/MCObjectStreamer.h" 16 | 17 | namespace llvm { 18 | 19 | class MCAsmBackend; 20 | class MCCodeEmitter; 21 | class MCExpr; 22 | class MCInst; 23 | 24 | class MCOMFStreamer : public MCObjectStreamer { 25 | public: 26 | MCOMFStreamer(MCContext &Context, std::unique_ptr TAB, 27 | raw_pwrite_stream &OS, std::unique_ptr Emitter) 28 | : MCObjectStreamer(Context, std::move(TAB), OS, std::move(Emitter)) {} 29 | 30 | ~MCOMFStreamer() override = default; 31 | 32 | bool EmitSymbolAttribute(MCSymbol *Symbol, MCSymbolAttr Attribute) override; 33 | void EmitCommonSymbol(MCSymbol *Symbol, uint64_t Size, 34 | unsigned ByteAlignment) override; 35 | void EmitZerofill(MCSection *Section, MCSymbol *Symbol = nullptr, 36 | uint64_t Size = 0, unsigned ByteAlignment = 0) override; 37 | void EmitInstToData(const MCInst &Inst, const MCSubtargetInfo &) override; 38 | }; 39 | 40 | 41 | 42 | MCOMFStreamer *createARMOMFStreamer(MCContext &Context, MCAsmBackend &TAB, 43 | raw_pwrite_stream &OS, 44 | MCCodeEmitter *Emitter, bool RelaxAll, 45 | bool IsThumb); 46 | 47 | } // end namespace llvm 48 | 49 | #endif // LLVM_MC_MCOMFSTREAMER_H 50 | -------------------------------------------------------------------------------- /lib/Target/Z80/InstPrinter/Z80InstPrinterBase.h: -------------------------------------------------------------------------------- 1 | //===- Z80InstPrinterBase.h - Convert Z80 MCInst to assembly ----*- C++ -*-===// 2 | // 3 | // The LLVM Compiler Infrastructure 4 | // 5 | // This file is distributed under the University of Illinois Open Source 6 | // License. See LICENSE.TXT for details. 7 | // 8 | //===----------------------------------------------------------------------===// 9 | // 10 | // This class prints a Z80 MCInst to a .s file. 11 | // 12 | //===----------------------------------------------------------------------===// 13 | 14 | #ifndef LLVM_LIB_TARGET_Z80_INSTPRINTER_Z80INSTPRINTERBASE_H 15 | #define LLVM_LIB_TARGET_Z80_INSTPRINTER_Z80INSTPRINTERBASE_H 16 | 17 | #include "llvm/MC/MCInstPrinter.h" 18 | 19 | namespace llvm { 20 | class Z80InstPrinterBase : public MCInstPrinter { 21 | public: 22 | Z80InstPrinterBase(const MCAsmInfo &MAI, const MCInstrInfo &MII, 23 | const MCRegisterInfo &MRI) 24 | : MCInstPrinter(MAI, MII, MRI) {} 25 | 26 | void printRegName(raw_ostream &OS, unsigned RegNo) const override; 27 | void printInst(const MCInst *MI, raw_ostream &OS, StringRef Annot, 28 | const MCSubtargetInfo &STI) override; 29 | 30 | // Autogenerated by tblgen. 31 | virtual void printInstruction(const MCInst *MI, raw_ostream &OS) = 0; 32 | virtual StringRef getRegName(unsigned RegNo) const = 0; 33 | 34 | void printOperand(const MCInst *MI, unsigned OpNo, raw_ostream &OS); 35 | void printCCOperand(const MCInst *MI, unsigned OpNo, raw_ostream &OS); 36 | 37 | void printMem(const MCInst *MI, unsigned OpNo, raw_ostream &OS); 38 | void printPtr(const MCInst *MI, unsigned OpNo, raw_ostream &OS); 39 | void printOff(const MCInst *MI, unsigned OpNo, raw_ostream &OS); 40 | void printAddr(const MCInst *MI, unsigned OpNo, raw_ostream &OS); 41 | }; 42 | } 43 | 44 | #endif 45 | -------------------------------------------------------------------------------- /lib/MC/MCOMFStreamer.cpp: -------------------------------------------------------------------------------- 1 | //===- lib/MC/MCOMFStreamer.cpp - OMF Object Output -----------------------===// 2 | // 3 | // The LLVM Compiler Infrastructure 4 | // 5 | // This file is distributed under the University of Illinois Open Source 6 | // License. See LICENSE.TXT for details. 7 | // 8 | //===----------------------------------------------------------------------===// 9 | // 10 | // This file assembles .s files and emits OMF .o object files. 11 | // 12 | //===----------------------------------------------------------------------===// 13 | 14 | #include "llvm/MC/MCOMFStreamer.h" 15 | #include "llvm/MC/MCAsmBackend.h" 16 | #include "llvm/MC/MCCodeEmitter.h" 17 | #include "llvm/Support/TargetRegistry.h" 18 | 19 | using namespace llvm; 20 | 21 | bool MCOMFStreamer::EmitSymbolAttribute(MCSymbol *Symbol, 22 | MCSymbolAttr Attribute) { 23 | llvm_unreachable("Unimplemented!"); 24 | } 25 | 26 | void MCOMFStreamer::EmitCommonSymbol(MCSymbol *Symbol, uint64_t Size, 27 | unsigned ByteAlignment) { 28 | llvm_unreachable("Unimplemented!"); 29 | } 30 | 31 | void MCOMFStreamer::EmitZerofill(MCSection *Section, MCSymbol *Symbol, 32 | uint64_t Size, unsigned ByteAlignment) { 33 | llvm_unreachable("Unimplemented!"); 34 | } 35 | 36 | void MCOMFStreamer::EmitInstToData(const MCInst &Inst, 37 | const MCSubtargetInfo &) { 38 | llvm_unreachable("Unimplemented!"); 39 | } 40 | 41 | MCStreamer *llvm::createOMFStreamer(MCContext &Context, 42 | std::unique_ptr &&MAB, 43 | raw_pwrite_stream &OS, 44 | std::unique_ptr &&CE, 45 | bool RelaxAll) { 46 | return new MCOMFStreamer(Context, std::move(MAB), OS, std::move(CE)); 47 | } 48 | -------------------------------------------------------------------------------- /lib/Target/Z80/MCTargetDesc/Z80MCCodeEmitter.cpp: -------------------------------------------------------------------------------- 1 | //===-- Z80MCCodeEmitter.cpp - Convert Z80 code to machine code -----------===// 2 | // 3 | // The LLVM Compiler Infrastructure 4 | // 5 | // This file is distributed under the University of Illinois Open Source 6 | // License. See LICENSE.TXT for details. 7 | // 8 | //===----------------------------------------------------------------------===// 9 | // 10 | // This file implements the Z80MCCodeEmitter class. 11 | // 12 | //===----------------------------------------------------------------------===// 13 | 14 | #include "Z80FixupKinds.h" 15 | #include "Z80MCTargetDesc.h" 16 | #include "llvm/MC/MCCodeEmitter.h" 17 | #include "llvm/MC/MCContext.h" 18 | #include "llvm/MC/MCInst.h" 19 | #include "llvm/MC/MCInstrInfo.h" 20 | #include "llvm/MC/MCRegisterInfo.h" 21 | #include "llvm/MC/MCSubtargetInfo.h" 22 | #include "llvm/Support/raw_ostream.h" 23 | using namespace llvm; 24 | 25 | namespace { 26 | 27 | class Z80MCCodeEmitter : public MCCodeEmitter { 28 | Z80MCCodeEmitter(const Z80MCCodeEmitter &) = delete; 29 | void operator=(const Z80MCCodeEmitter &) = delete; 30 | const MCInstrInfo &MII; 31 | MCContext &Ctx; 32 | public: 33 | Z80MCCodeEmitter(const MCInstrInfo &mii, MCContext &ctx) 34 | : MII(mii), Ctx(ctx) {} 35 | 36 | ~Z80MCCodeEmitter() override {} 37 | 38 | void encodeInstruction(const MCInst &MI, raw_ostream &OS, 39 | SmallVectorImpl &Fixups, 40 | const MCSubtargetInfo &STI) const override; 41 | }; 42 | 43 | } // end anonymous namespace 44 | 45 | void Z80MCCodeEmitter::encodeInstruction(const MCInst &MC, raw_ostream &OS, 46 | SmallVectorImpl &Fixups, 47 | const MCSubtargetInfo &STI) const { 48 | llvm_unreachable("Unimplemented"); 49 | } 50 | 51 | MCCodeEmitter *llvm::createZ80MCCodeEmitter(const MCInstrInfo &MII, 52 | const MCRegisterInfo &MRI, 53 | MCContext &Ctx) { 54 | return new Z80MCCodeEmitter(MII, Ctx); 55 | } 56 | -------------------------------------------------------------------------------- /lib/Target/Z80/MCTargetDesc/Z80MCAsmInfo.cpp: -------------------------------------------------------------------------------- 1 | //===-- Z80MCAsmInfo.cpp - Z80 asm properties -----------------------------===// 2 | // 3 | // The LLVM Compiler Infrastructure 4 | // 5 | // This file is distributed under the University of Illinois Open Source 6 | // License. See LICENSE.TXT for details. 7 | // 8 | //===----------------------------------------------------------------------===// 9 | // 10 | // This file contains the declarations of the Z80MCAsmInfo properties. 11 | // 12 | //===----------------------------------------------------------------------===// 13 | 14 | #include "Z80MCAsmInfo.h" 15 | #include "llvm/ADT/StringSwitch.h" 16 | #include "llvm/ADT/Triple.h" 17 | using namespace llvm; 18 | 19 | void Z80MCAsmInfo::anchor() { } 20 | 21 | Z80MCAsmInfo::Z80MCAsmInfo(const Triple &T) { 22 | bool Is16Bit = T.isArch16Bit() || T.getEnvironment() == Triple::CODE16; 23 | CodePointerSize = CalleeSaveStackSlotSize = Is16Bit ? 2 : 3; 24 | MaxInstLength = 6; 25 | DollarIsPC = true; 26 | SeparatorString = nullptr; 27 | CommentString = ";"; 28 | PrivateGlobalPrefix = PrivateLabelPrefix = ""; 29 | Code16Directive = ".assume\tadl = 0"; 30 | Code24Directive = ".assume\tadl = 1"; 31 | Code32Directive = Code64Directive = nullptr; 32 | AssemblerDialect = !Is16Bit; 33 | SupportsQuotedNames = false; 34 | ZeroDirective = AsciiDirective = AscizDirective = nullptr; 35 | Data8bitsDirective = "\tDB\t"; 36 | Data16bitsDirective = "\tDW\t"; 37 | Data24bitsDirective = "\tDW24\t"; 38 | Data32bitsDirective = "\tDL\t"; 39 | Data64bitsDirective = nullptr; 40 | AssignmentDirective = " EQU "; 41 | GlobalDirective = "\tXDEF\t"; 42 | HasFunctionAlignment = false; 43 | HasDotTypeDotSizeDirective = false; 44 | WeakDirective = nullptr; 45 | UseIntegratedAssembler = false; 46 | WeakDirective = nullptr; 47 | UseLogicalShr = false; 48 | } 49 | 50 | const char *Z80MCAsmInfo::getBlockDirective(int64_t Size) const { 51 | switch (Size) { 52 | default: return nullptr; 53 | case 1: return "\tBLKB\t"; 54 | case 2: return "\tBLKW\t"; 55 | case 3: return "\tBLKP\t"; 56 | case 4: return "\tBLKL\t"; 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /lib/Target/LLVMBuild.txt: -------------------------------------------------------------------------------- 1 | ;===- ./lib/Target/LLVMBuild.txt -------------------------------*- Conf -*--===; 2 | ; 3 | ; The LLVM Compiler Infrastructure 4 | ; 5 | ; This file is distributed under the University of Illinois Open Source 6 | ; License. See LICENSE.TXT for details. 7 | ; 8 | ;===------------------------------------------------------------------------===; 9 | ; 10 | ; This is an LLVMBuild description file for the components in this subdirectory. 11 | ; 12 | ; For more information on the LLVMBuild system, please see: 13 | ; 14 | ; http://llvm.org/docs/LLVMBuild.html 15 | ; 16 | ;===------------------------------------------------------------------------===; 17 | 18 | ; Please keep these as one per line so that out-of-tree merges 19 | ; will typically require only insertion of a line. 20 | [common] 21 | subdirectories = 22 | AMDGPU 23 | ARC 24 | ARM 25 | AArch64 26 | AVR 27 | BPF 28 | Lanai 29 | Hexagon 30 | MSP430 31 | NVPTX 32 | Mips 33 | Nios2 34 | PowerPC 35 | RISCV 36 | Sparc 37 | SystemZ 38 | WebAssembly 39 | X86 40 | XCore 41 | Z80 42 | 43 | ; This is a special group whose required libraries are extended (by llvm-build) 44 | ; with the best execution engine (the native JIT, if available, or the 45 | ; interpreter). 46 | [component_0] 47 | type = LibraryGroup 48 | name = Engine 49 | parent = Libraries 50 | 51 | ; This is a special group whose required libraries are extended (by llvm-build) 52 | ; with the configured native target, if any. 53 | [component_1] 54 | type = LibraryGroup 55 | name = Native 56 | parent = Libraries 57 | 58 | ; This is a special group whose required libraries are extended (by llvm-build) 59 | ; with the configured native code generator, if any. 60 | [component_2] 61 | type = LibraryGroup 62 | name = NativeCodeGen 63 | parent = Libraries 64 | 65 | ; The component for the actual target library itself. 66 | [component_3] 67 | type = Library 68 | name = Target 69 | parent = Libraries 70 | required_libraries = Analysis Core MC Support 71 | 72 | ; This is a special group whose required libraries are extended (by llvm-build) 73 | ; with every built target, which makes it easy for tools to include every 74 | ; target. 75 | [component_4] 76 | type = LibraryGroup 77 | name = all-targets 78 | parent = Libraries 79 | -------------------------------------------------------------------------------- /tools/clang/lib/Driver/ToolChains/ZDS.h: -------------------------------------------------------------------------------- 1 | //===--- ZDS.h - ZDS ToolChain Implementations ------------------*- C++ -*-===// 2 | // 3 | // The LLVM Compiler Infrastructure 4 | // 5 | // This file is distributed under the University of Illinois Open Source 6 | // License. See LICENSE.TXT for details. 7 | // 8 | //===----------------------------------------------------------------------===// 9 | 10 | #ifndef LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_ZDS_H 11 | #define LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_ZDS_H 12 | 13 | #include "clang/Driver/Tool.h" 14 | #include "clang/Driver/ToolChain.h" 15 | 16 | namespace clang { 17 | namespace driver { 18 | namespace tools { 19 | 20 | // Zilog Developer Studio tools 21 | namespace ZDS { 22 | class LLVM_LIBRARY_VISIBILITY Assembler : public Tool { 23 | public: 24 | explicit Assembler(const ToolChain &TC) 25 | : Tool("ZDS::Assembler", "assembler", TC) {} 26 | 27 | bool hasIntegratedCPP() const override { return false; } 28 | 29 | void ConstructJob(Compilation &C, const JobAction &JA, 30 | const InputInfo &Output, const InputInfoList &Inputs, 31 | const llvm::opt::ArgList &TCArgs, 32 | const char *LinkingOutput) const override; 33 | }; 34 | 35 | class LLVM_LIBRARY_VISIBILITY Linker : public Tool { 36 | public: 37 | explicit Linker(const ToolChain &TC) 38 | : Tool("ZDS::Linker", "linker", TC) {} 39 | 40 | bool hasIntegratedCPP() const override { return false; } 41 | bool isLinkJob() const override { return true; } 42 | 43 | void ConstructJob(Compilation &C, const JobAction &JA, 44 | const InputInfo &Output, const InputInfoList &Inputs, 45 | const llvm::opt::ArgList &TCArgs, 46 | const char *LinkingOutput) const override; 47 | }; 48 | } // end namespace zds 49 | 50 | } // end namespace tools 51 | 52 | namespace toolchains { 53 | 54 | class LLVM_LIBRARY_VISIBILITY ZDSToolChain : public ToolChain { 55 | public: 56 | ZDSToolChain(const Driver &D, const llvm::Triple &T, 57 | const llvm::opt::ArgList &Args); 58 | 59 | bool IsIntegratedAssemblerDefault() const override { return false; } 60 | bool isPICDefault() const override { return false; } 61 | bool isPIEDefault() const override { return false; } 62 | bool isPICDefaultForced() const override { return false; } 63 | 64 | protected: 65 | Tool *buildAssembler() const override; 66 | Tool *buildLinker() const override; 67 | }; 68 | 69 | } // end namespace toolchains 70 | } // end namespace driver 71 | } // end namespace clang 72 | 73 | #endif // LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_ZDS_H 74 | -------------------------------------------------------------------------------- /lib/Target/ARM/LICENSE.TXT: -------------------------------------------------------------------------------- 1 | ARM Limited 2 | 3 | Software Grant License Agreement ("Agreement") 4 | 5 | Except for the license granted herein to you, ARM Limited ("ARM") reserves all 6 | right, title, and interest in and to the Software (defined below). 7 | 8 | Definition 9 | 10 | "Software" means the code and documentation as well as any original work of 11 | authorship, including any modifications or additions to an existing work, that 12 | is intentionally submitted by ARM to llvm.org (http://llvm.org) ("LLVM") for 13 | inclusion in, or documentation of, any of the products owned or managed by LLVM 14 | (the "Work"). For the purposes of this definition, "submitted" means any form of 15 | electronic, verbal, or written communication sent to LLVM or its 16 | representatives, including but not limited to communication on electronic 17 | mailing lists, source code control systems, and issue tracking systems that are 18 | managed by, or on behalf of, LLVM for the purpose of discussing and improving 19 | the Work, but excluding communication that is conspicuously marked otherwise. 20 | 21 | 1. Grant of Copyright License. Subject to the terms and conditions of this 22 | Agreement, ARM hereby grants to you and to recipients of the Software 23 | distributed by LLVM a perpetual, worldwide, non-exclusive, no-charge, 24 | royalty-free, irrevocable copyright license to reproduce, prepare derivative 25 | works of, publicly display, publicly perform, sublicense, and distribute the 26 | Software and such derivative works. 27 | 28 | 2. Grant of Patent License. Subject to the terms and conditions of this 29 | Agreement, ARM hereby grants you and to recipients of the Software 30 | distributed by LLVM a perpetual, worldwide, non-exclusive, no-charge, 31 | royalty-free, irrevocable (except as stated in this section) patent license 32 | to make, have made, use, offer to sell, sell, import, and otherwise transfer 33 | the Work, where such license applies only to those patent claims licensable 34 | by ARM that are necessarily infringed by ARM's Software alone or by 35 | combination of the Software with the Work to which such Software was 36 | submitted. If any entity institutes patent litigation against ARM or any 37 | other entity (including a cross-claim or counterclaim in a lawsuit) alleging 38 | that ARM's Software, or the Work to which ARM has contributed constitutes 39 | direct or contributory patent infringement, then any patent licenses granted 40 | to that entity under this Agreement for the Software or Work shall terminate 41 | as of the date such litigation is filed. 42 | 43 | Unless required by applicable law or agreed to in writing, the software is 44 | provided on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 45 | either express or implied, including, without limitation, any warranties or 46 | conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 47 | PARTICULAR PURPOSE. 48 | -------------------------------------------------------------------------------- /lib/Target/Z80/MCTargetDesc/Z80MCTargetDesc.h: -------------------------------------------------------------------------------- 1 | //===-- Z80MCTargetDesc.h - Z80 Target Descriptions -------------*- C++ -*-===// 2 | // 3 | // The LLVM Compiler Infrastructure 4 | // 5 | // This file is distributed under the University of Illinois Open Source 6 | // License. See LICENSE.TXT for details. 7 | // 8 | //===----------------------------------------------------------------------===// 9 | // 10 | // This file provides Z80 specific target descriptions. 11 | // 12 | //===----------------------------------------------------------------------===// 13 | 14 | #ifndef LLVM_LIB_TARGET_Z80_MCTARGETDESC_Z80MCTARGETDESC_H 15 | #define LLVM_LIB_TARGET_Z80_MCTARGETDESC_Z80MCTARGETDESC_H 16 | 17 | #include "llvm/Support/DataTypes.h" 18 | #include 19 | #include 20 | 21 | namespace llvm { 22 | class MCAsmBackend; 23 | class MCCodeEmitter; 24 | class MCContext; 25 | class MCInstrInfo; 26 | class MCObjectWriter; 27 | class MCRegisterInfo; 28 | class MCSubtargetInfo; 29 | class MCTargetOptions; 30 | class Target; 31 | class Triple; 32 | class StringRef; 33 | class raw_pwrite_stream; 34 | 35 | Target &getTheZ80Target(); 36 | Target &getTheEZ80Target(); 37 | 38 | namespace Z80_MC { 39 | std::string ParseZ80Triple(const Triple &TT); 40 | 41 | /// Create a Z80 MCSubtargetInfo instance. This is exposed so Asm parser, etc. 42 | /// do not need to go through TargetRegistry. 43 | MCSubtargetInfo *createZ80MCSubtargetInfo(const Triple &TT, StringRef CPU, 44 | StringRef FS); 45 | } 46 | 47 | MCCodeEmitter *createZ80MCCodeEmitter(const MCInstrInfo &MCII, 48 | const MCRegisterInfo &MRI, 49 | MCContext &Ctx); 50 | 51 | MCAsmBackend *createZ80AsmBackend(const Target &T, const MCRegisterInfo &MRI, 52 | const Triple &TT, StringRef CPU, 53 | const MCTargetOptions &Options); 54 | MCAsmBackend *createEZ80AsmBackend(const Target &T, const MCRegisterInfo &MRI, 55 | const Triple &TT, StringRef CPU, 56 | const MCTargetOptions &Options); 57 | 58 | /// Construct a Z80 OMF object writer. 59 | std::unique_ptr createZ80OMFObjectWriter(raw_pwrite_stream &OS); 60 | 61 | /// Construct a Z80 ELF object writer. 62 | std::unique_ptr createZ80ELFObjectWriter(raw_pwrite_stream &OS, 63 | uint8_t OSABI = 0); 64 | 65 | } // End llvm namespace 66 | 67 | // Defines symbolic names for Z80 registers. This defines a mapping from 68 | // register name to register number. 69 | // 70 | #define GET_REGINFO_ENUM 71 | #include "Z80GenRegisterInfo.inc" 72 | 73 | // Defines symbolic names for the Z80 instructions. 74 | // 75 | #define GET_INSTRINFO_ENUM 76 | #include "Z80GenInstrInfo.inc" 77 | 78 | #define GET_SUBTARGETINFO_ENUM 79 | #include "Z80GenSubtargetInfo.inc" 80 | 81 | #endif 82 | -------------------------------------------------------------------------------- /tools/clang/LICENSE.TXT: -------------------------------------------------------------------------------- 1 | ============================================================================== 2 | LLVM Release License 3 | ============================================================================== 4 | University of Illinois/NCSA 5 | Open Source License 6 | 7 | Copyright (c) 2007-2016 University of Illinois at Urbana-Champaign. 8 | All rights reserved. 9 | 10 | Developed by: 11 | 12 | LLVM Team 13 | 14 | University of Illinois at Urbana-Champaign 15 | 16 | http://llvm.org 17 | 18 | Permission is hereby granted, free of charge, to any person obtaining a copy of 19 | this software and associated documentation files (the "Software"), to deal with 20 | the Software without restriction, including without limitation the rights to 21 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 22 | of the Software, and to permit persons to whom the Software is furnished to do 23 | so, subject to the following conditions: 24 | 25 | * Redistributions of source code must retain the above copyright notice, 26 | this list of conditions and the following disclaimers. 27 | 28 | * Redistributions in binary form must reproduce the above copyright notice, 29 | this list of conditions and the following disclaimers in the 30 | documentation and/or other materials provided with the distribution. 31 | 32 | * Neither the names of the LLVM Team, University of Illinois at 33 | Urbana-Champaign, nor the names of its contributors may be used to 34 | endorse or promote products derived from this Software without specific 35 | prior written permission. 36 | 37 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 38 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 39 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 40 | CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 41 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 42 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE 43 | SOFTWARE. 44 | 45 | ============================================================================== 46 | The LLVM software contains code written by third parties. Such software will 47 | have its own individual LICENSE.TXT file in the directory in which it appears. 48 | This file will describe the copyrights, license, and restrictions which apply 49 | to that code. 50 | 51 | The disclaimer of warranty in the University of Illinois Open Source License 52 | applies to all code in the LLVM Distribution, and nothing in any of the 53 | other licenses gives permission to use the names of the LLVM Team or the 54 | University of Illinois to endorse or promote products derived from this 55 | Software. 56 | 57 | The following pieces of software have additional or alternate copyrights, 58 | licenses, and/or restrictions: 59 | 60 | Program Directory 61 | ------- --------- 62 | 63 | 64 | -------------------------------------------------------------------------------- /lib/Target/Z80/Z80FrameLowering.h: -------------------------------------------------------------------------------- 1 | //===-- Z80TargetFrameLowering.h - Define frame lowering for Z80 -*- C++ -*-==// 2 | // 3 | // The LLVM Compiler Infrastructure 4 | // 5 | // This file is distributed under the University of Illinois Open Source 6 | // License. See LICENSE.TXT for details. 7 | // 8 | //===----------------------------------------------------------------------===// 9 | // 10 | // This class implements z80-specific bits of TargetFrameLowering class. 11 | // 12 | //===----------------------------------------------------------------------===// 13 | 14 | #ifndef LLVM_LIB_TARGET_Z80_Z80FRAMELOWERING_H 15 | #define LLVM_LIB_TARGET_Z80_Z80FRAMELOWERING_H 16 | 17 | #include "llvm/CodeGen/TargetFrameLowering.h" 18 | 19 | namespace llvm { 20 | class Z80Subtarget; 21 | class Z80InstrInfo; 22 | class Z80RegisterInfo; 23 | 24 | class Z80FrameLowering : public TargetFrameLowering { 25 | const Z80Subtarget &STI; 26 | const Z80InstrInfo &TII; 27 | const Z80RegisterInfo *TRI; 28 | 29 | bool Is24Bit; 30 | unsigned SlotSize; 31 | 32 | public: 33 | explicit Z80FrameLowering(const Z80Subtarget &STI); 34 | 35 | /// emitProlog/emitEpilog - These methods insert prolog and epilog code into 36 | /// the function. 37 | void emitPrologue(MachineFunction &MF, MachineBasicBlock &MBB) const override; 38 | void emitEpilogue(MachineFunction &MF, MachineBasicBlock &MBB) const override; 39 | 40 | bool assignCalleeSavedSpillSlots( 41 | MachineFunction &MF, const TargetRegisterInfo *TRI, 42 | std::vector &CSI) const override; 43 | bool spillCalleeSavedRegisters(MachineBasicBlock &MBB, 44 | MachineBasicBlock::iterator MI, 45 | const std::vector &CSI, 46 | const TargetRegisterInfo *TRI) const override; 47 | bool restoreCalleeSavedRegisters(MachineBasicBlock &MBB, 48 | MachineBasicBlock::iterator MI, 49 | std::vector &CSI, 50 | const TargetRegisterInfo *TRI) const override; 51 | 52 | void processFunctionBeforeFrameFinalized( 53 | MachineFunction &MF, RegScavenger *RS = nullptr) const override; 54 | 55 | MachineBasicBlock::iterator eliminateCallFramePseudoInstr( 56 | MachineFunction &MF, MachineBasicBlock &MBB, 57 | MachineBasicBlock::iterator MI) const override; 58 | 59 | bool hasFP(const MachineFunction &MF) const override; 60 | 61 | private: 62 | void BuildStackAdjustment(MachineFunction &MF, MachineBasicBlock &MBB, 63 | MachineBasicBlock::iterator MBBI, DebugLoc DL, 64 | unsigned ScratchReg, int Offset, 65 | int FPOffset = -1, 66 | bool UnknownOffset = false) const; 67 | 68 | void shadowCalleeSavedRegisters( 69 | MachineBasicBlock &MBB, MachineBasicBlock::iterator MI, DebugLoc DL, 70 | MachineInstr::MIFlag Flag, const std::vector &CSI) const; 71 | }; 72 | } // End llvm namespace 73 | 74 | #endif 75 | -------------------------------------------------------------------------------- /tools/clang/lib/Basic/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(LLVM_LINK_COMPONENTS 2 | Core 3 | MC 4 | Support 5 | ) 6 | 7 | find_first_existing_vc_file(llvm_vc "${LLVM_MAIN_SRC_DIR}") 8 | find_first_existing_vc_file(clang_vc "${CLANG_SOURCE_DIR}") 9 | 10 | # The VC revision include that we want to generate. 11 | set(version_inc "${CMAKE_CURRENT_BINARY_DIR}/SVNVersion.inc") 12 | 13 | set(get_svn_script "${LLVM_CMAKE_PATH}/GetSVN.cmake") 14 | 15 | if(DEFINED llvm_vc AND DEFINED clang_vc) 16 | # Create custom target to generate the VC revision include. 17 | add_custom_command(OUTPUT "${version_inc}" 18 | DEPENDS "${llvm_vc}" "${clang_vc}" "${get_svn_script}" 19 | COMMAND 20 | ${CMAKE_COMMAND} "-DFIRST_SOURCE_DIR=${LLVM_MAIN_SRC_DIR}" 21 | "-DFIRST_NAME=LLVM" 22 | "-DSECOND_SOURCE_DIR=${CLANG_SOURCE_DIR}" 23 | "-DSECOND_NAME=SVN" 24 | "-DHEADER_FILE=${version_inc}" 25 | -P "${get_svn_script}") 26 | 27 | # Mark the generated header as being generated. 28 | set_source_files_properties("${version_inc}" 29 | PROPERTIES GENERATED TRUE 30 | HEADER_FILE_ONLY TRUE) 31 | 32 | # Tell Version.cpp that it needs to build with -DHAVE_SVN_VERSION_INC. 33 | set_source_files_properties(Version.cpp 34 | PROPERTIES COMPILE_DEFINITIONS "HAVE_SVN_VERSION_INC") 35 | else() 36 | # Not producing a VC revision include. 37 | set(version_inc) 38 | 39 | # Being able to force-set the SVN revision in cases where it isn't available 40 | # is useful for performance tracking, and matches compatibility from autoconf. 41 | if(SVN_REVISION) 42 | set_source_files_properties(Version.cpp 43 | PROPERTIES COMPILE_DEFINITIONS "SVN_REVISION=\"${SVN_REVISION}\"") 44 | endif() 45 | endif() 46 | 47 | add_clang_library(clangBasic 48 | Attributes.cpp 49 | Builtins.cpp 50 | CharInfo.cpp 51 | Cuda.cpp 52 | Diagnostic.cpp 53 | DiagnosticIDs.cpp 54 | DiagnosticOptions.cpp 55 | FileManager.cpp 56 | FileSystemStatCache.cpp 57 | IdentifierTable.cpp 58 | LangOptions.cpp 59 | MemoryBufferCache.cpp 60 | Module.cpp 61 | ObjCRuntime.cpp 62 | OpenMPKinds.cpp 63 | OperatorPrecedence.cpp 64 | SanitizerBlacklist.cpp 65 | SanitizerSpecialCaseList.cpp 66 | Sanitizers.cpp 67 | SourceLocation.cpp 68 | SourceManager.cpp 69 | TargetInfo.cpp 70 | Targets.cpp 71 | Targets/AArch64.cpp 72 | Targets/AMDGPU.cpp 73 | Targets/ARM.cpp 74 | Targets/AVR.cpp 75 | Targets/BPF.cpp 76 | Targets/Hexagon.cpp 77 | Targets/Lanai.cpp 78 | Targets/Le64.cpp 79 | Targets/MSP430.cpp 80 | Targets/Mips.cpp 81 | Targets/NVPTX.cpp 82 | Targets/Nios2.cpp 83 | Targets/OSTargets.cpp 84 | Targets/PNaCl.cpp 85 | Targets/PPC.cpp 86 | Targets/SPIR.cpp 87 | Targets/Sparc.cpp 88 | Targets/SystemZ.cpp 89 | Targets/TCE.cpp 90 | Targets/WebAssembly.cpp 91 | Targets/X86.cpp 92 | Targets/XCore.cpp 93 | Targets/Z80.cpp 94 | TokenKinds.cpp 95 | Version.cpp 96 | VersionTuple.cpp 97 | VirtualFileSystem.cpp 98 | Warnings.cpp 99 | XRayLists.cpp 100 | ${version_inc} 101 | ) 102 | 103 | -------------------------------------------------------------------------------- /include/llvm/MC/MCDirectives.h: -------------------------------------------------------------------------------- 1 | //===- MCDirectives.h - Enums for directives on various targets -*- C++ -*-===// 2 | // 3 | // The LLVM Compiler Infrastructure 4 | // 5 | // This file is distributed under the University of Illinois Open Source 6 | // License. See LICENSE.TXT for details. 7 | // 8 | //===----------------------------------------------------------------------===// 9 | // 10 | // This file defines various enums that represent target-specific directives. 11 | // 12 | //===----------------------------------------------------------------------===// 13 | 14 | #ifndef LLVM_MC_MCDIRECTIVES_H 15 | #define LLVM_MC_MCDIRECTIVES_H 16 | 17 | namespace llvm { 18 | 19 | enum MCSymbolAttr { 20 | MCSA_Invalid = 0, ///< Not a valid directive. 21 | 22 | // Various directives in alphabetical order. 23 | MCSA_ELF_TypeFunction, ///< .type _foo, STT_FUNC # aka @function 24 | MCSA_ELF_TypeIndFunction, ///< .type _foo, STT_GNU_IFUNC 25 | MCSA_ELF_TypeObject, ///< .type _foo, STT_OBJECT # aka @object 26 | MCSA_ELF_TypeTLS, ///< .type _foo, STT_TLS # aka @tls_object 27 | MCSA_ELF_TypeCommon, ///< .type _foo, STT_COMMON # aka @common 28 | MCSA_ELF_TypeNoType, ///< .type _foo, STT_NOTYPE # aka @notype 29 | MCSA_ELF_TypeGnuUniqueObject, /// .type _foo, @gnu_unique_object 30 | MCSA_Global, ///< .globl 31 | MCSA_Hidden, ///< .hidden (ELF) 32 | MCSA_IndirectSymbol, ///< .indirect_symbol (MachO) 33 | MCSA_Internal, ///< .internal (ELF) 34 | MCSA_LazyReference, ///< .lazy_reference (MachO) 35 | MCSA_Local, ///< .local (ELF) 36 | MCSA_NoDeadStrip, ///< .no_dead_strip (MachO) 37 | MCSA_SymbolResolver, ///< .symbol_resolver (MachO) 38 | MCSA_AltEntry, ///< .alt_entry (MachO) 39 | MCSA_PrivateExtern, ///< .private_extern (MachO) 40 | MCSA_Protected, ///< .protected (ELF) 41 | MCSA_Reference, ///< .reference (MachO) 42 | MCSA_Weak, ///< .weak 43 | MCSA_WeakDefinition, ///< .weak_definition (MachO) 44 | MCSA_WeakReference, ///< .weak_reference (MachO) 45 | MCSA_WeakDefAutoPrivate ///< .weak_def_can_be_hidden (MachO) 46 | }; 47 | 48 | enum MCAssemblerFlag { 49 | MCAF_SyntaxUnified, ///< .syntax (ARM/ELF) 50 | MCAF_SubsectionsViaSymbols, ///< .subsections_via_symbols (MachO) 51 | MCAF_Code16, ///< .code16 (X86) / .code 16 (ARM) 52 | MCAF_Code24, ///< (EZ80) 53 | MCAF_Code32, ///< .code32 (X86) / .code 32 (ARM) 54 | MCAF_Code64 ///< .code64 (X86) 55 | }; 56 | 57 | enum MCDataRegionType { 58 | MCDR_DataRegion, ///< .data_region 59 | MCDR_DataRegionJT8, ///< .data_region jt8 60 | MCDR_DataRegionJT16, ///< .data_region jt16 61 | MCDR_DataRegionJT32, ///< .data_region jt32 62 | MCDR_DataRegionEnd ///< .end_data_region 63 | }; 64 | 65 | enum MCVersionMinType { 66 | MCVM_IOSVersionMin, ///< .ios_version_min 67 | MCVM_OSXVersionMin, ///< .macosx_version_min 68 | MCVM_TvOSVersionMin, ///< .tvos_version_min 69 | MCVM_WatchOSVersionMin, ///< .watchos_version_min 70 | }; 71 | 72 | } // end namespace llvm 73 | 74 | #endif 75 | -------------------------------------------------------------------------------- /lib/Target/Z80/AsmParser/Z80AsmParser.cpp: -------------------------------------------------------------------------------- 1 | //===-- Z80AsmParser.cpp - Parse Z80 assembly to MCInst instructions ------===// 2 | // 3 | // The LLVM Compiler Infrastructure 4 | // 5 | // This file is distributed under the University of Illinois Open Source 6 | // License. See LICENSE.TXT for details. 7 | // 8 | //===----------------------------------------------------------------------===// 9 | 10 | #include "MCTargetDesc/Z80MCTargetDesc.h" 11 | #include "Z80Operand.h" 12 | #include "llvm/MC/MCInst.h" 13 | #include "llvm/MC/MCParser/MCAsmParser.h" 14 | #include "llvm/MC/MCParser/MCTargetAsmParser.h" 15 | #include "llvm/MC/SubtargetFeature.h" 16 | #include "llvm/Support/TargetRegistry.h" 17 | using namespace llvm; 18 | 19 | namespace { 20 | 21 | class Z80AsmParser : public MCTargetAsmParser { 22 | ParseInstructionInfo *InstInfo; 23 | 24 | bool MatchAndEmitInstruction(SMLoc IDLoc, unsigned &Opcode, 25 | OperandVector &Operands, MCStreamer &Out, 26 | uint64_t &ErrorInfo, 27 | bool MatchingInlineAsm) override; 28 | 29 | /// @name Auto-generated Matcher Functions 30 | /// { 31 | 32 | #define GET_ASSEMBLER_HEADER 33 | #include "Z80GenAsmMatcher.inc" 34 | 35 | /// } 36 | 37 | public: 38 | Z80AsmParser(const MCSubtargetInfo &sti, MCAsmParser &Parser, 39 | const MCInstrInfo &mii, const MCTargetOptions &Options) 40 | : MCTargetAsmParser(Options, sti, mii), InstInfo(nullptr) {} 41 | 42 | bool ParseRegister(unsigned &RegNo, SMLoc &StartLoc, SMLoc &EndLoc) override; 43 | 44 | bool ParseInstruction(ParseInstructionInfo &Info, StringRef Name, 45 | SMLoc NameLoc, OperandVector &Operands) override; 46 | 47 | bool ParseDirective(AsmToken DirectiveID) override; 48 | }; 49 | 50 | } // end anonymous namespace 51 | 52 | bool Z80AsmParser::MatchAndEmitInstruction(SMLoc IDLoc, unsigned &Opcode, 53 | OperandVector &Operands, 54 | MCStreamer &Out, uint64_t &ErrorInfo, 55 | bool MatchingInlineAsm) { 56 | llvm_unreachable("Unimplemented"); 57 | } 58 | 59 | bool Z80AsmParser::ParseRegister(unsigned &RegNo, SMLoc &StartLoc, 60 | SMLoc &EndLoc) { 61 | llvm_unreachable("Unimplemented"); 62 | } 63 | 64 | bool Z80AsmParser::ParseInstruction(ParseInstructionInfo &Info, StringRef Name, 65 | SMLoc NameLoc, OperandVector &Operands) { 66 | llvm_unreachable("Unimplemented"); 67 | } 68 | 69 | bool Z80AsmParser::ParseDirective(AsmToken DirectiveID) { 70 | llvm_unreachable("Unimplemented"); 71 | } 72 | 73 | // Force static initialization. 74 | extern "C" void LLVMInitializeZ80AsmParser() { 75 | RegisterMCAsmParser X(getTheZ80Target()); 76 | RegisterMCAsmParser Y(getTheEZ80Target()); 77 | } 78 | 79 | namespace { 80 | struct MatchEntry; 81 | } 82 | namespace std { 83 | inline const MatchEntry *begin(const MatchEntry array[]) { return array; } 84 | inline const MatchEntry *end(const MatchEntry array[]) { return array; } 85 | } 86 | 87 | #define GET_REGISTER_MATCHER 88 | #define GET_MATCHER_IMPLEMENTATION 89 | #define GET_SUBTARGET_FEATURE_NAME 90 | #include "Z80GenAsmMatcher.inc" 91 | -------------------------------------------------------------------------------- /lib/Target/Z80/InstPrinter/Z80InstPrinterBase.cpp: -------------------------------------------------------------------------------- 1 | //===- Z80InstPrinter.cpp - Convert Z80 MCInst to assembly ------*- C++ -*-===// 2 | // 3 | // The LLVM Compiler Infrastructure 4 | // 5 | // This file is distributed under the University of Illinois Open Source 6 | // License. See LICENSE.TXT for details. 7 | // 8 | //===----------------------------------------------------------------------===// 9 | // 10 | // This class prints a Z80 MCInst to a .s file. 11 | // 12 | //===----------------------------------------------------------------------===// 13 | 14 | #include "Z80InstPrinterBase.h" 15 | #include "Z80InstPrinter.h" 16 | #include "llvm/MC/MCExpr.h" 17 | #include "llvm/MC/MCInst.h" 18 | #include "llvm/Support/ErrorHandling.h" 19 | #include "llvm/Support/FormattedStream.h" 20 | using namespace llvm; 21 | 22 | #define DEBUG_TYPE "asm-printer" 23 | 24 | void Z80InstPrinterBase::printRegName(raw_ostream &OS, unsigned RegNo) const { 25 | OS << markup(""); 26 | } 27 | 28 | void Z80InstPrinterBase::printInst(const MCInst *MI, raw_ostream &OS, 29 | StringRef Annot, const MCSubtargetInfo &STI) { 30 | printInstruction(MI, OS); 31 | printAnnotation(OS, Annot); 32 | } 33 | 34 | void Z80InstPrinterBase::printOperand(const MCInst *MI, unsigned OpNo, 35 | raw_ostream &OS) { 36 | const MCOperand &Op = MI->getOperand(OpNo); 37 | if (Op.isReg()) { 38 | printRegName(OS, Op.getReg()); 39 | } else if (Op.isImm()) { 40 | OS << Op.getImm(); 41 | } else { 42 | assert(Op.isExpr() && "unknown operand kind in printOperand"); 43 | OS << markup("print(OS, &MAI); 45 | OS << markup(">"); 46 | } 47 | } 48 | void Z80InstPrinterBase::printCCOperand(const MCInst *MI, unsigned Op, 49 | raw_ostream &OS) { 50 | switch (MI->getOperand(Op).getImm()) { 51 | default: llvm_unreachable("Invalid CC operand!"); 52 | case 0: OS << "nz"; break; 53 | case 1: OS << "z"; break; 54 | case 2: OS << "nc"; break; 55 | case 3: OS << "c"; break; 56 | case 4: OS << "po"; break; 57 | case 5: OS << "pe"; break; 58 | case 6: OS << "p"; break; 59 | case 7: OS << "m"; break; 60 | } 61 | } 62 | 63 | void Z80InstPrinterBase::printMem(const MCInst *MI, unsigned Op, 64 | raw_ostream &OS) { 65 | OS << markup("");; 68 | } 69 | void Z80InstPrinterBase::printPtr(const MCInst *MI, unsigned Op, 70 | raw_ostream &OS) { 71 | OS << markup(""); 74 | } 75 | void Z80InstPrinterBase::printOff(const MCInst *MI, unsigned Op, 76 | raw_ostream &OS) { 77 | OS << markup(""); 80 | } 81 | void Z80InstPrinterBase::printAddr(const MCInst *MI, unsigned Op, 82 | raw_ostream &OS) { 83 | printOperand(MI, Op, OS); 84 | int8_t Off = MI->getOperand(Op+1).getImm(); 85 | assert(Off == MI->getOperand(Op+1).getImm() && "Offset out of range!"); 86 | OS << " + " << int(MI->getOperand(Op+1).getImm()); 87 | } 88 | -------------------------------------------------------------------------------- /include/llvm/BinaryFormat/Magic.h: -------------------------------------------------------------------------------- 1 | //===- llvm/BinaryFormat/Magic.h - File magic identification ----*- C++ -*-===// 2 | // 3 | // The LLVM Compiler Infrastructure 4 | // 5 | // This file is distributed under the University of Illinois Open Source 6 | // License. See LICENSE.TXT for details. 7 | // 8 | //===----------------------------------------------------------------------===// 9 | 10 | #ifndef LLVM_BINARYFORMAT_MAGIC_H 11 | #define LLVM_BINARYFORMAT_MAGIC_H 12 | 13 | #include "llvm/ADT/StringRef.h" 14 | #include "llvm/ADT/Twine.h" 15 | 16 | #include 17 | 18 | namespace llvm { 19 | /// file_magic - An "enum class" enumeration of file types based on magic (the 20 | /// first N bytes of the file). 21 | struct file_magic { 22 | enum Impl { 23 | unknown = 0, ///< Unrecognized file 24 | bitcode, ///< Bitcode file 25 | archive, ///< ar style archive file 26 | elf, ///< ELF Unknown type 27 | elf_relocatable, ///< ELF Relocatable object file 28 | elf_executable, ///< ELF Executable image 29 | elf_shared_object, ///< ELF dynamically linked shared lib 30 | elf_core, ///< ELF core image 31 | macho_object, ///< Mach-O Object file 32 | macho_executable, ///< Mach-O Executable 33 | macho_fixed_virtual_memory_shared_lib, ///< Mach-O Shared Lib, FVM 34 | macho_core, ///< Mach-O Core File 35 | macho_preload_executable, ///< Mach-O Preloaded Executable 36 | macho_dynamically_linked_shared_lib, ///< Mach-O dynlinked shared lib 37 | macho_dynamic_linker, ///< The Mach-O dynamic linker 38 | macho_bundle, ///< Mach-O Bundle file 39 | macho_dynamically_linked_shared_lib_stub, ///< Mach-O Shared lib stub 40 | macho_dsym_companion, ///< Mach-O dSYM companion file 41 | macho_kext_bundle, ///< Mach-O kext bundle file 42 | macho_universal_binary, ///< Mach-O universal binary 43 | coff_cl_gl_object, ///< Microsoft cl.exe's intermediate code file 44 | coff_object, ///< COFF object file 45 | coff_import_library, ///< COFF import library 46 | pecoff_executable, ///< PECOFF executable file 47 | windows_resource, ///< Windows compiled resource file (.res) 48 | wasm_object, ///< WebAssembly Object file 49 | omf_object, ///< IEEE 695 OMF assembler file 50 | omf_archive ///< IEEE 695 OMF LIBRARY file 51 | }; 52 | 53 | bool is_object() const { return V != unknown; } 54 | 55 | file_magic() = default; 56 | file_magic(Impl V) : V(V) {} 57 | operator Impl() const { return V; } 58 | 59 | private: 60 | Impl V = unknown; 61 | }; 62 | 63 | /// @brief Identify the type of a binary file based on how magical it is. 64 | file_magic identify_magic(StringRef magic); 65 | 66 | /// @brief Get and identify \a path's type based on its content. 67 | /// 68 | /// @param path Input path. 69 | /// @param result Set to the type of file, or file_magic::unknown. 70 | /// @returns errc::success if result has been successfully set, otherwise a 71 | /// platform-specific error_code. 72 | std::error_code identify_magic(const Twine &path, file_magic &result); 73 | } // namespace llvm 74 | 75 | #endif 76 | -------------------------------------------------------------------------------- /tools/clang/lib/Basic/Targets/Z80.cpp: -------------------------------------------------------------------------------- 1 | //===--- Z80.cpp - Implement Z80 target feature support -------------------===// 2 | // 3 | // The LLVM Compiler Infrastructure 4 | // 5 | // This file is distributed under the University of Illinois Open Source 6 | // License. See LICENSE.TXT for details. 7 | // 8 | //===----------------------------------------------------------------------===// 9 | // 10 | // This file implements Z80 TargetInfo objects. 11 | // 12 | //===----------------------------------------------------------------------===// 13 | 14 | #include "Z80.h" 15 | #include "llvm/ADT/StringSwitch.h" 16 | 17 | using namespace clang; 18 | using namespace clang::targets; 19 | 20 | bool Z80TargetInfo::setCPU(const std::string &Name) { 21 | return llvm::StringSwitch(Name) 22 | .Case("generic", true) 23 | .Case("z80", true) 24 | .Case("z180", true) 25 | .Default(false); 26 | } 27 | 28 | bool Z80TargetInfo:: 29 | initFeatureMap(llvm::StringMap &Features, 30 | DiagnosticsEngine &Diags, StringRef CPU, 31 | const std::vector &FeaturesVec) const { 32 | if (CPU == "z80") 33 | Features["undoc"] = true; 34 | if (CPU == "z180") 35 | Features["z180"] = true; 36 | return TargetInfo::initFeatureMap(Features, Diags, CPU, FeaturesVec); 37 | } 38 | 39 | ArrayRef Z80TargetInfo::getGCCRegNames() const { 40 | static const char *const GCCRegNames[] = { 41 | "a", "f", "b", "c", "d", "e", "h", "l", 42 | "a'", "f'", "b'", "c'", "d'", "e'", "h'", "l'", 43 | "ixh", "ixl", "iyh", "iyl", "i", "r", 44 | "af", "bc", "de", "hl", "af'", "bc'", "de'", "hl'", 45 | "ix", "iy", "sp", "pc" 46 | }; 47 | return GCCRegNames; 48 | } 49 | 50 | void Z80TargetInfo::getTargetDefines(const LangOptions &Opts, 51 | MacroBuilder &Builder) const { 52 | Z80TargetInfoBase::getTargetDefines(Opts, Builder); 53 | defineCPUMacros(Builder, "Z80", /*Tuning=*/false); 54 | if (getTargetOpts().CPU == "undoc") 55 | defineCPUMacros(Builder, "Z80_UNDOC", /*Tuning=*/false); 56 | else if (getTargetOpts().CPU == "z180") 57 | defineCPUMacros(Builder, "Z180", /*Tuning=*/false); 58 | } 59 | 60 | bool EZ80TargetInfo::setCPU(const std::string &Name) { 61 | return llvm::StringSwitch(Name) 62 | .Case("generic", true) 63 | .Case("ez80", true) 64 | .Default(false); 65 | } 66 | 67 | ArrayRef EZ80TargetInfo::getGCCRegNames() const { 68 | static const char *const GCCRegNames[] = { 69 | "a", "f", "b", "c", "d", "e", "h", "l", 70 | "a'", "f'", "b'", "c'", "d'", "e'", "h'", "l'", 71 | "ixh", "ixl", "iyh", "iyl", "i", "r", 72 | "af", "bc", "de", "hl", "af'", "bc'", "de'", "hl'", 73 | "ix", "iy", "sp", "pc", 74 | "ubc", "ude", "uhl", "ubc'", "ude'", "uhl'", "uix", "uiy", "spl" 75 | }; 76 | return GCCRegNames; 77 | } 78 | 79 | ArrayRef EZ80TargetInfo::getGCCRegAliases() const { 80 | static const TargetInfo::GCCRegAlias GCCRegAliases[] = {{{"sps"}, "sp"}}; 81 | return GCCRegAliases; 82 | } 83 | 84 | void EZ80TargetInfo::getTargetDefines(const LangOptions &Opts, 85 | MacroBuilder &Builder) const { 86 | Z80TargetInfoBase::getTargetDefines(Opts, Builder); 87 | defineCPUMacros(Builder, "EZ80", /*Tuning=*/false); 88 | } 89 | -------------------------------------------------------------------------------- /tools/clang/lib/Driver/ToolChains/ZDS.cpp: -------------------------------------------------------------------------------- 1 | //===--- ZDSToolChain.cpp - ZDS Tool Chain --------------------------------===// 2 | // 3 | // The LLVM Compiler Infrastructure 4 | // 5 | // This file is distributed under the University of Illinois Open Source 6 | // License. See LICENSE.TXT for details. 7 | // 8 | //===----------------------------------------------------------------------===// 9 | 10 | #include "ZDS.h" 11 | #include "CommonArgs.h" 12 | #include "clang/Driver/Compilation.h" 13 | #include "clang/Driver/Options.h" 14 | #include "llvm/Option/ArgList.h" 15 | #include "llvm/Support/FileSystem.h" 16 | #include "llvm/Support/Path.h" 17 | 18 | using namespace clang::driver; 19 | using namespace clang::driver::toolchains; 20 | using namespace llvm::opt; 21 | 22 | void tools::ZDS::Assembler::ConstructJob( 23 | Compilation &C, const JobAction &JA, const InputInfo &Output, 24 | const InputInfoList &Inputs, const ArgList &Args, 25 | const char *LinkingOutput) const { 26 | assert(Inputs.size() == 1); 27 | claimNoWarnArgs(Args); 28 | 29 | InputInfo TempInput = Inputs[0], TempOutput = Output; 30 | while (true) { 31 | llvm::StringRef InputStem = llvm::sys::path::stem(TempInput.getFilename()); 32 | TempOutput.setFilename(Args.MakeArgString(InputStem + ".obj")); 33 | if (llvm::sys::path::has_extension(TempInput.getFilename()) && 34 | !llvm::sys::fs::exists(TempOutput.getFilename())) 35 | break; 36 | TempInput.setFilename(C.addTempFile( 37 | Args.MakeArgString(C.getDriver().GetTemporaryPath(InputStem, "asm")))); 38 | } 39 | 40 | if (Inputs[0].getFilename() != TempInput.getFilename()) 41 | C.addCommand( 42 | llvm::make_unique(JA, *this, Inputs[0], TempInput)); 43 | 44 | const char *Exec = 45 | Args.MakeArgString(getToolChain().GetProgramPath("ez80asm.exe")); 46 | ArgStringList CmdArgs; 47 | CmdArgs.push_back("-quiet"); // Suppress title 48 | CmdArgs.push_back("-cpu:EZ80F91"); // Suppress a warning 49 | CmdArgs.push_back("-NOlist"); // Suppress list file 50 | Args.AddAllArgValues(CmdArgs, options::OPT_Wa_COMMA, options::OPT_Xassembler); 51 | SmallString<128> WindowsInput; 52 | llvm::sys::path::native(TempInput.getFilename(), WindowsInput, 53 | llvm::sys::path::Style::windows); 54 | CmdArgs.push_back(Args.MakeArgString(WindowsInput)); 55 | C.addCommand(llvm::make_unique(JA, *this, Exec, CmdArgs, TempInput)); 56 | 57 | if (std::strcmp(TempOutput.getFilename(), Output.getFilename())) { 58 | C.addResultFile(TempOutput.getFilename(), &JA); 59 | C.addCommand( 60 | llvm::make_unique(JA, *this, TempOutput, Output)); 61 | } 62 | } 63 | 64 | void tools::ZDS::Linker::ConstructJob( 65 | Compilation &C, const JobAction &JA, const InputInfo &Output, 66 | const InputInfoList &Inputs, const ArgList &Args, 67 | const char *LinkingOutput) const { 68 | llvm_unreachable("Unimplemented!"); 69 | } 70 | 71 | ZDSToolChain::ZDSToolChain(const Driver &D, const llvm::Triple &Triple, 72 | const ArgList &Args) 73 | : ToolChain(D, Triple, Args) {} 74 | 75 | Tool *ZDSToolChain::buildAssembler() const { 76 | return new tools::ZDS::Assembler(*this); 77 | } 78 | 79 | Tool *ZDSToolChain::buildLinker() const { 80 | return new tools::ZDS::Linker(*this); 81 | } 82 | -------------------------------------------------------------------------------- /include/llvm/CodeGen/RuntimeLibcalls.h: -------------------------------------------------------------------------------- 1 | //===-- CodeGen/RuntimeLibcalls.h - Runtime Library Calls -------*- C++ -*-===// 2 | // 3 | // The LLVM Compiler Infrastructure 4 | // 5 | // This file is distributed under the University of Illinois Open Source 6 | // License. See LICENSE.TXT for details. 7 | // 8 | //===----------------------------------------------------------------------===// 9 | // 10 | // This file defines the enum representing the list of runtime library calls 11 | // the backend may emit during code generation, and also some helper functions. 12 | // 13 | //===----------------------------------------------------------------------===// 14 | 15 | #ifndef LLVM_CODEGEN_RUNTIMELIBCALLS_H 16 | #define LLVM_CODEGEN_RUNTIMELIBCALLS_H 17 | 18 | #include "llvm/CodeGen/ValueTypes.h" 19 | 20 | namespace llvm { 21 | namespace RTLIB { 22 | /// RTLIB::Libcall enum - This enum defines all of the runtime library calls 23 | /// the backend can emit. The various long double types cannot be merged, 24 | /// because 80-bit library functions use "xf" and 128-bit use "tf". 25 | /// 26 | /// When adding PPCF128 functions here, note that their names generally need 27 | /// to be overridden for Darwin with the xxx$LDBL128 form. See 28 | /// PPCISelLowering.cpp. 29 | /// 30 | enum Libcall { 31 | #define HANDLE_LIBCALL(code, name) code, 32 | #include "RuntimeLibcalls.def" 33 | #undef HANDLE_LIBCALL 34 | }; 35 | 36 | /// getFPEXT - Return the FPEXT_*_* value for the given types, or 37 | /// UNKNOWN_LIBCALL if there is none. 38 | Libcall getFPEXT(EVT OpVT, EVT RetVT); 39 | 40 | /// getFPROUND - Return the FPROUND_*_* value for the given types, or 41 | /// UNKNOWN_LIBCALL if there is none. 42 | Libcall getFPROUND(EVT OpVT, EVT RetVT); 43 | 44 | /// getFPTOSINT - Return the FPTOSINT_*_* value for the given types, or 45 | /// UNKNOWN_LIBCALL if there is none. 46 | Libcall getFPTOSINT(EVT OpVT, EVT RetVT); 47 | 48 | /// getFPTOUINT - Return the FPTOUINT_*_* value for the given types, or 49 | /// UNKNOWN_LIBCALL if there is none. 50 | Libcall getFPTOUINT(EVT OpVT, EVT RetVT); 51 | 52 | /// getSINTTOFP - Return the SINTTOFP_*_* value for the given types, or 53 | /// UNKNOWN_LIBCALL if there is none. 54 | Libcall getSINTTOFP(EVT OpVT, EVT RetVT); 55 | 56 | /// getUINTTOFP - Return the UINTTOFP_*_* value for the given types, or 57 | /// UNKNOWN_LIBCALL if there is none. 58 | Libcall getUINTTOFP(EVT OpVT, EVT RetVT); 59 | 60 | /// Return the SYNC_FETCH_AND_* value for the given opcode and type, or 61 | /// UNKNOWN_LIBCALL if there is none. 62 | Libcall getSYNC(unsigned Opc, MVT VT); 63 | 64 | /// getMEMCPY_ELEMENT_UNORDERED_ATOMIC - Return 65 | /// MEMCPY_ELEMENT_UNORDERED_ATOMIC_* value for the given element size or 66 | /// UNKNOW_LIBCALL if there is none. 67 | Libcall getMEMCPY_ELEMENT_UNORDERED_ATOMIC(uint64_t ElementSize); 68 | 69 | /// getMEMMOVE_ELEMENT_UNORDERED_ATOMIC - Return 70 | /// MEMMOVE_ELEMENT_UNORDERED_ATOMIC_* value for the given element size or 71 | /// UNKNOW_LIBCALL if there is none. 72 | Libcall getMEMMOVE_ELEMENT_UNORDERED_ATOMIC(uint64_t ElementSize); 73 | 74 | /// getMEMSET_ELEMENT_UNORDERED_ATOMIC - Return 75 | /// MEMSET_ELEMENT_UNORDERED_ATOMIC_* value for the given element size or 76 | /// UNKNOW_LIBCALL if there is none. 77 | Libcall getMEMSET_ELEMENT_UNORDERED_ATOMIC(uint64_t ElementSize); 78 | 79 | } 80 | } 81 | 82 | #endif 83 | -------------------------------------------------------------------------------- /LICENSE.TXT: -------------------------------------------------------------------------------- 1 | ============================================================================== 2 | LLVM Release License 3 | ============================================================================== 4 | University of Illinois/NCSA 5 | Open Source License 6 | 7 | Copyright (c) 2003-2017 University of Illinois at Urbana-Champaign. 8 | All rights reserved. 9 | 10 | Developed by: 11 | 12 | LLVM Team 13 | 14 | University of Illinois at Urbana-Champaign 15 | 16 | http://llvm.org 17 | 18 | Permission is hereby granted, free of charge, to any person obtaining a copy of 19 | this software and associated documentation files (the "Software"), to deal with 20 | the Software without restriction, including without limitation the rights to 21 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 22 | of the Software, and to permit persons to whom the Software is furnished to do 23 | so, subject to the following conditions: 24 | 25 | * Redistributions of source code must retain the above copyright notice, 26 | this list of conditions and the following disclaimers. 27 | 28 | * Redistributions in binary form must reproduce the above copyright notice, 29 | this list of conditions and the following disclaimers in the 30 | documentation and/or other materials provided with the distribution. 31 | 32 | * Neither the names of the LLVM Team, University of Illinois at 33 | Urbana-Champaign, nor the names of its contributors may be used to 34 | endorse or promote products derived from this Software without specific 35 | prior written permission. 36 | 37 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 38 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 39 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 40 | CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 41 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 42 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE 43 | SOFTWARE. 44 | 45 | ============================================================================== 46 | Copyrights and Licenses for Third Party Software Distributed with LLVM: 47 | ============================================================================== 48 | The LLVM software contains code written by third parties. Such software will 49 | have its own individual LICENSE.TXT file in the directory in which it appears. 50 | This file will describe the copyrights, license, and restrictions which apply 51 | to that code. 52 | 53 | The disclaimer of warranty in the University of Illinois Open Source License 54 | applies to all code in the LLVM Distribution, and nothing in any of the 55 | other licenses gives permission to use the names of the LLVM Team or the 56 | University of Illinois to endorse or promote products derived from this 57 | Software. 58 | 59 | The following pieces of software have additional or alternate copyrights, 60 | licenses, and/or restrictions: 61 | 62 | Program Directory 63 | ------- --------- 64 | Google Test llvm/utils/unittest/googletest 65 | OpenBSD regex llvm/lib/Support/{reg*, COPYRIGHT.regex} 66 | pyyaml tests llvm/test/YAMLParser/{*.data, LICENSE.TXT} 67 | ARM contributions llvm/lib/Target/ARM/LICENSE.TXT 68 | md5 contributions llvm/lib/Support/MD5.cpp llvm/include/llvm/Support/MD5.h 69 | -------------------------------------------------------------------------------- /lib/Target/Z80/Z80CallingConv.td: -------------------------------------------------------------------------------- 1 | //===-- Z80CallingConv.td - Calling Conventions Z80/EZ80 ---*- tablegen -*-===// 2 | // 3 | // The LLVM Compiler Infrastructure 4 | // 5 | // This file is distributed under the University of Illinois Open Source 6 | // License. See LICENSE.TXT for details. 7 | // 8 | //===----------------------------------------------------------------------===// 9 | // 10 | // This describes the calling conventions for the Z80 and EZ80 architectures. 11 | // 12 | //===----------------------------------------------------------------------===// 13 | 14 | //===----------------------------------------------------------------------===// 15 | // Z80 Argument Calling Conventions 16 | //===----------------------------------------------------------------------===// 17 | 18 | def CC_Z80_C : CallingConv<[ 19 | CCIfByVal>, 20 | CCIfType<[i1, i8], CCPromoteToType>, 21 | CCIfType<[i16], CCAssignToStack<2, 1>>, 22 | CCIfType<[i32, f32], CCAssignToStack<4, 1>>, 23 | CCIfType<[i64, f64], CCAssignToStack<8, 1>> 24 | ]>; 25 | def CC_EZ80_C : CallingConv<[ 26 | CCIfByVal>, 27 | CCIfType<[i1, i8, i16], CCPromoteToType>, 28 | CCIfType<[i24], CCAssignToStack<3, 1>>, 29 | CCIfType<[i32, f32, i48], CCAssignToStack<6, 1>>, 30 | CCIfType<[i64, f64], CCAssignToStack<9, 1>> 31 | ]>; 32 | 33 | def CC_EZ80_LC : CallingConv<[ 34 | CCIfType<[i24], CCIfSplit>>, 35 | CCIfType<[i24], CCIfSplitEnd>>, 36 | CCIfType<[i24], CCAssignToRegWithShadow<[UHL, UBC], [UDE, UIY]>>, 37 | CCIfType<[i16], CCIfSplit>>, 38 | CCIfType<[i16], CCIfSplitEnd>>, 39 | CCIfType<[i16], CCAssignToRegWithShadow<[HL, BC], [DE, IY]>> 40 | ]>; 41 | def CC_EZ80_LC_AB : CallingConv<[ 42 | CCDelegateTo, 43 | CCIfType<[i8], CCAssignToReg<[A, B]>> 44 | ]>; 45 | def CC_EZ80_LC_AC : CallingConv<[ 46 | CCDelegateTo, 47 | CCIfType<[i8], CCAssignToReg<[A, C]>> 48 | ]>; 49 | def CC_EZ80_LC_BC : CallingConv<[ 50 | CCDelegateTo, 51 | CCIfType<[i8], CCAssignToReg<[B, C]>> 52 | ]>; 53 | def CC_EZ80_LC_C : CallingConv<[ 54 | CCDelegateTo, 55 | CCIfType<[i8], CCAssignToReg<[C]>> 56 | ]>; 57 | def CC_EZ80_LC_L : CallingConv<[ 58 | CCIfType<[i24], CCAssignToReg<[UBC]>>, 59 | CCDelegateTo, 60 | CCIfType<[i8], CCAssignToReg<[A, L]>> 61 | ]>; 62 | 63 | //===----------------------------------------------------------------------===// 64 | // Return Value Calling Conventions 65 | //===----------------------------------------------------------------------===// 66 | def RetCC_Z80_C : CallingConv<[ 67 | CCIfType<[i16], CCAssignToReg<[HL, DE, BC, IY]>>, 68 | CCIfType<[i8], CCAssignToReg<[A, L, H, E, D, C, B, IYL, IYH]>> 69 | ]>; 70 | def RetCC_EZ80_C : CallingConv<[ 71 | CCDelegateTo, 72 | CCIfType<[i8], CCAssignToReg<[A, E]>> 73 | ]>; 74 | def RetCC_EZ80_LC_L : CallingConv<[ 75 | CCIfType<[i24], CCAssignToReg<[UBC]>>, 76 | CCIfType<[i8], CCAssignToReg<[A]>> 77 | ]>; 78 | 79 | //===----------------------------------------------------------------------===// 80 | // Callee-saved Registers. 81 | //===----------------------------------------------------------------------===// 82 | 83 | def CSR_NoRegs : CalleeSavedRegs<(add)>; 84 | def CSR_Z80_C : CalleeSavedRegs<(add IX)>; 85 | def CSR_EZ80_C : CalleeSavedRegs<(add UIX)>; 86 | def CSR_Z80_AllRegs : CalleeSavedRegs<(add R16, AF)>; 87 | def CSR_EZ80_AllRegs : CalleeSavedRegs<(add R24, AF)>; 88 | -------------------------------------------------------------------------------- /lib/Object/SymbolicFile.cpp: -------------------------------------------------------------------------------- 1 | //===- SymbolicFile.cpp - Interface that only provides symbols ------------===// 2 | // 3 | // The LLVM Compiler Infrastructure 4 | // 5 | // This file is distributed under the University of Illinois Open Source 6 | // License. See LICENSE.TXT for details. 7 | // 8 | //===----------------------------------------------------------------------===// 9 | // 10 | // This file defines a file format independent SymbolicFile class. 11 | // 12 | //===----------------------------------------------------------------------===// 13 | 14 | #include "llvm/Object/SymbolicFile.h" 15 | #include "llvm/ADT/StringRef.h" 16 | #include "llvm/BinaryFormat/Magic.h" 17 | #include "llvm/Object/COFFImportFile.h" 18 | #include "llvm/Object/Error.h" 19 | #include "llvm/Object/IRObjectFile.h" 20 | #include "llvm/Object/ObjectFile.h" 21 | #include "llvm/Support/Compiler.h" 22 | #include "llvm/Support/Error.h" 23 | #include "llvm/Support/ErrorHandling.h" 24 | #include "llvm/Support/ErrorOr.h" 25 | #include "llvm/Support/FileSystem.h" 26 | #include "llvm/Support/MemoryBuffer.h" 27 | #include 28 | #include 29 | 30 | using namespace llvm; 31 | using namespace object; 32 | 33 | SymbolicFile::SymbolicFile(unsigned int Type, MemoryBufferRef Source) 34 | : Binary(Type, Source) {} 35 | 36 | SymbolicFile::~SymbolicFile() = default; 37 | 38 | Expected> 39 | SymbolicFile::createSymbolicFile(MemoryBufferRef Object, file_magic Type, 40 | LLVMContext *Context) { 41 | StringRef Data = Object.getBuffer(); 42 | if (Type == file_magic::unknown) 43 | Type = identify_magic(Data); 44 | 45 | switch (Type) { 46 | case file_magic::bitcode: 47 | if (Context) 48 | return IRObjectFile::create(Object, *Context); 49 | LLVM_FALLTHROUGH; 50 | case file_magic::unknown: 51 | case file_magic::archive: 52 | case file_magic::coff_cl_gl_object: 53 | case file_magic::macho_universal_binary: 54 | case file_magic::windows_resource: 55 | case file_magic::omf_archive: 56 | return errorCodeToError(object_error::invalid_file_type); 57 | case file_magic::elf: 58 | case file_magic::elf_executable: 59 | case file_magic::elf_shared_object: 60 | case file_magic::elf_core: 61 | case file_magic::macho_executable: 62 | case file_magic::macho_fixed_virtual_memory_shared_lib: 63 | case file_magic::macho_core: 64 | case file_magic::macho_preload_executable: 65 | case file_magic::macho_dynamically_linked_shared_lib: 66 | case file_magic::macho_dynamic_linker: 67 | case file_magic::macho_bundle: 68 | case file_magic::macho_dynamically_linked_shared_lib_stub: 69 | case file_magic::macho_dsym_companion: 70 | case file_magic::macho_kext_bundle: 71 | case file_magic::pecoff_executable: 72 | case file_magic::wasm_object: 73 | case file_magic::omf_object: 74 | return ObjectFile::createObjectFile(Object, Type); 75 | case file_magic::coff_import_library: 76 | return std::unique_ptr(new COFFImportFile(Object)); 77 | case file_magic::elf_relocatable: 78 | case file_magic::macho_object: 79 | case file_magic::coff_object: { 80 | Expected> Obj = 81 | ObjectFile::createObjectFile(Object, Type); 82 | if (!Obj || !Context) 83 | return std::move(Obj); 84 | 85 | Expected BCData = 86 | IRObjectFile::findBitcodeInObject(*Obj->get()); 87 | if (!BCData) { 88 | consumeError(BCData.takeError()); 89 | return std::move(Obj); 90 | } 91 | 92 | return IRObjectFile::create( 93 | MemoryBufferRef(BCData->getBuffer(), Object.getBufferIdentifier()), 94 | *Context); 95 | } 96 | } 97 | llvm_unreachable("Unexpected Binary File Type"); 98 | } 99 | -------------------------------------------------------------------------------- /tools/llvm-readobj/OMFDumper.cpp: -------------------------------------------------------------------------------- 1 | //===-- OMFDumper.cpp - OMF-specific dumper ---------------------*- C++ -*-===// 2 | // 3 | // The LLVM Compiler Infrastructure 4 | // 5 | // This file is distributed under the University of Illinois Open Source 6 | // License. See LICENSE.TXT for details. 7 | // 8 | //===----------------------------------------------------------------------===// 9 | /// 10 | /// \file 11 | /// \brief This file implements the OMF-specific dumper for llvm-readobj. 12 | /// 13 | //===----------------------------------------------------------------------===// 14 | 15 | #include "Error.h" 16 | #include "ObjDumper.h" 17 | #include "llvm-readobj.h" 18 | #include "llvm/Object/OMFObjectFile.h" 19 | #include "llvm/Support/ScopedPrinter.h" 20 | 21 | using namespace llvm; 22 | using namespace object; 23 | using namespace support; 24 | 25 | namespace { 26 | 27 | class OMFDumper : public ObjDumper { 28 | const OMFObjectFile *Obj; 29 | public: 30 | OMFDumper(const OMFObjectFile *Obj, ScopedPrinter &Writer) 31 | : ObjDumper(Writer), Obj(Obj) {} 32 | 33 | void printFileHeaders() override; 34 | void printSections() override; 35 | void printRelocations() override; 36 | void printSymbols() override; 37 | void printDynamicSymbols() override; 38 | void printUnwindInfo() override; 39 | void printStackMap() const override; 40 | }; 41 | 42 | } // end namespace 43 | 44 | namespace llvm { 45 | 46 | std::error_code createOMFDumper(const object::ObjectFile *Obj, 47 | ScopedPrinter &Writer, 48 | std::unique_ptr &Result) { 49 | if (const OMFObjectFile *OMFObj = dyn_cast(Obj)) { 50 | Result.reset(new OMFDumper(OMFObj, Writer)); 51 | return readobj_error::success; 52 | } 53 | return readobj_error::unsupported_obj_file_format; 54 | } 55 | 56 | } // namespace llvm 57 | 58 | void OMFDumper::printFileHeaders() { 59 | DictScope D(W, "ModuleBegin"); 60 | W.printString("Processor", Obj->getProcessor()); 61 | W.printString("ModuleName", Obj->getModuleName()); 62 | W.printNumber("MAUBits", Obj->getMAUBits()); 63 | W.printNumber("AddrMAUs", Obj->getAddrMAUs()); 64 | } 65 | 66 | void OMFDumper::printSections() { 67 | ListScope Sections(W, "Sections"); 68 | for (const SectionRef &Sec : Obj->sections()) { 69 | StringRef Name; 70 | error(Sec.getName(Name)); 71 | 72 | DictScope Section(W, "Section"); 73 | W.printString("Name", Name); 74 | W.printBinary("Type", Obj->getSectionType(Sec)); 75 | W.printHex("Address", Sec.getAddress()); 76 | W.printHex("Size", Sec.getSize()); 77 | W.printHex("Alignment", Sec.getAlignment()); 78 | 79 | if (opts::SectionData && !Sec.isVirtual()) { 80 | StringRef Data; 81 | error(Sec.getContents(Data)); 82 | W.printBinaryBlock("Data", Data); 83 | } 84 | } 85 | } 86 | 87 | void OMFDumper::printRelocations() { 88 | llvm_unreachable("Unimplemented!"); 89 | } 90 | 91 | void OMFDumper::printSymbols() { 92 | ListScope Symbols(W, "Symbols"); 93 | 94 | for (const SymbolRef &Symb : Obj->symbols()) { 95 | StringRef SecName; 96 | error(unwrapOrError(Symb.getSection())->getName(SecName)); 97 | 98 | DictScope Symbol(W, "Symbol"); 99 | W.printString("Name", unwrapOrError(Symb.getName())); 100 | W.printString("Section", SecName); 101 | W.printHex("Address", unwrapOrError(Symb.getAddress())); 102 | } 103 | } 104 | 105 | void OMFDumper::printDynamicSymbols() { 106 | llvm_unreachable("Unimplemented!"); 107 | } 108 | 109 | void OMFDumper::printUnwindInfo() { 110 | llvm_unreachable("Unimplemented!"); 111 | } 112 | 113 | void OMFDumper::printStackMap() const { 114 | llvm_unreachable("Unimplemented!"); 115 | } 116 | -------------------------------------------------------------------------------- /lib/Target/Z80/MCTargetDesc/Z80AsmBackend.cpp: -------------------------------------------------------------------------------- 1 | //===-- Z80AsmBackend.cpp - Z80 Assembler Backend -------------------------===// 2 | // 3 | // The LLVM Compiler Infrastructure 4 | // 5 | // This file is distributed under the University of Illinois Open Source 6 | // License. See LICENSE.TXT for details. 7 | // 8 | //===----------------------------------------------------------------------===// 9 | 10 | #include "Z80FixupKinds.h" 11 | #include "Z80MCTargetDesc.h" 12 | #include "llvm/MC/MCAsmBackend.h" 13 | #include "llvm/MC/MCOMFObjectWriter.h" 14 | #include "llvm/MC/MCObjectWriter.h" 15 | #include "llvm/MC/MCRegisterInfo.h" 16 | #include "llvm/Support/TargetRegistry.h" 17 | using namespace llvm; 18 | 19 | namespace { 20 | 21 | class Z80AsmBackend : public MCAsmBackend { 22 | public: 23 | Z80AsmBackend(const Target &T) 24 | : MCAsmBackend() {} 25 | 26 | unsigned getNumFixupKinds() const override { 27 | return Z80::NumTargetFixupKinds; 28 | } 29 | 30 | void applyFixup(const MCAssembler &Asm, const MCFixup &Fixup, 31 | const MCValue &Target, MutableArrayRef Data, 32 | uint64_t Value, bool IsResolved) const override; 33 | 34 | bool mayNeedRelaxation(const MCInst &Inst) const override; 35 | 36 | bool fixupNeedsRelaxation(const MCFixup &Fixup, uint64_t Value, 37 | const MCRelaxableFragment *DF, 38 | const MCAsmLayout &Layout) const override; 39 | 40 | void relaxInstruction(const MCInst &Inst, const MCSubtargetInfo &STI, 41 | MCInst &Res) const override; 42 | 43 | bool writeNopData(uint64_t Count, MCObjectWriter *OW) const override { 44 | OW->WriteZeros(Count); 45 | return true; 46 | } 47 | }; 48 | 49 | } // end anonymous namespace 50 | 51 | void Z80AsmBackend::applyFixup(const MCAssembler &Asm, const MCFixup &Fixup, 52 | const MCValue &Target, 53 | MutableArrayRef Data, uint64_t Value, 54 | bool IsResolved) const { 55 | llvm_unreachable("Unimplemented"); 56 | } 57 | 58 | bool Z80AsmBackend::mayNeedRelaxation(const MCInst &Inst) const { 59 | llvm_unreachable("Unimplemented"); 60 | } 61 | 62 | bool Z80AsmBackend::fixupNeedsRelaxation(const MCFixup &Fixup, uint64_t Value, 63 | const MCRelaxableFragment *DF, 64 | const MCAsmLayout &Layout) const { 65 | llvm_unreachable("Unimplemented"); 66 | } 67 | 68 | void Z80AsmBackend::relaxInstruction(const MCInst &Inst, 69 | const MCSubtargetInfo &STI, 70 | MCInst &Res) const { 71 | llvm_unreachable("Unimplemented"); 72 | } 73 | 74 | namespace { 75 | 76 | class OMFZ80AsmBackend : public Z80AsmBackend { 77 | public: 78 | OMFZ80AsmBackend(const Target &T) : Z80AsmBackend(T) {} 79 | 80 | std::unique_ptr 81 | createObjectWriter(raw_pwrite_stream &OS) const override { 82 | return createZ80OMFObjectWriter(OS); 83 | } 84 | }; 85 | 86 | } // end anonymous namespace 87 | 88 | MCAsmBackend *llvm::createZ80AsmBackend(const Target &T, 89 | const MCRegisterInfo &MRI, 90 | const Triple &TheTriple, StringRef CPU, 91 | const MCTargetOptions &Options) { 92 | return new OMFZ80AsmBackend(T); 93 | } 94 | 95 | MCAsmBackend *llvm::createEZ80AsmBackend(const Target &T, 96 | const MCRegisterInfo &MRI, 97 | const Triple &TheTriple, StringRef CPU, 98 | const MCTargetOptions &Options) { 99 | return new OMFZ80AsmBackend(T); 100 | } 101 | -------------------------------------------------------------------------------- /lib/Target/Z80/Z80Subtarget.h: -------------------------------------------------------------------------------- 1 | //===-- Z80Subtarget.h - Define Subtarget for the Z80 ----------*- C++ -*--===// 2 | // 3 | // The LLVM Compiler Infrastructure 4 | // 5 | // This file is distributed under the University of Illinois Open Source 6 | // License. See LICENSE.TXT for details. 7 | // 8 | //===----------------------------------------------------------------------===// 9 | // 10 | // This file declares the Z80 specific subclass of TargetSubtargetInfo. 11 | // 12 | //===----------------------------------------------------------------------===// 13 | 14 | #ifndef LLVM_LIB_TARGET_Z80_Z80SUBTARGET_H 15 | #define LLVM_LIB_TARGET_Z80_Z80SUBTARGET_H 16 | 17 | #include "Z80FrameLowering.h" 18 | #include "Z80ISelLowering.h" 19 | #include "Z80InstrInfo.h" 20 | #include "Z80SelectionDAGInfo.h" 21 | #include "llvm/CodeGen/TargetSubtargetInfo.h" 22 | 23 | #define GET_SUBTARGETINFO_HEADER 24 | #include "Z80GenSubtargetInfo.inc" 25 | 26 | namespace llvm { 27 | class Z80TargetMachine; 28 | 29 | class Z80Subtarget final : public Z80GenSubtargetInfo { 30 | /// What processor and OS we're targeting. 31 | Triple TargetTriple; 32 | 33 | /// True if compiling for 16-bit, false for 24-bit. 34 | bool In16BitMode; 35 | 36 | /// True if compiling for 24-bit, false for 16-bit. 37 | bool In24BitMode; 38 | 39 | /// True if target has undocumented z80 instructions. 40 | bool HasUndocOps; 41 | 42 | /// True if target has z180 instructions. 43 | bool HasZ180Ops; 44 | 45 | /// True if target has ez80 instructions. 46 | bool HasEZ80Ops; 47 | 48 | /// True if target has index half registers (HasUndocOps || HasEZ80Ops). 49 | bool HasIdxHalfRegs; 50 | 51 | Z80SelectionDAGInfo TSInfo; 52 | // Ordering here is important. Z80InstrInfo initializes Z80RegisterInfo which 53 | // Z80TargetLowering needs. 54 | Z80InstrInfo InstrInfo; 55 | Z80TargetLowering TLInfo; 56 | Z80FrameLowering FrameLowering; 57 | 58 | public: 59 | /// This constructor initializes the data members to match that 60 | /// of the specified triple. 61 | Z80Subtarget(const Triple &TT, const std::string &CPU, const std::string &FS, 62 | const Z80TargetMachine &TM); 63 | 64 | //bool enableSubRegLiveness() const override { return true; } 65 | 66 | const Z80SelectionDAGInfo *getSelectionDAGInfo() const override { 67 | return &TSInfo; 68 | } 69 | const Z80TargetLowering *getTargetLowering() const override { 70 | return &TLInfo; 71 | } 72 | const Z80InstrInfo *getInstrInfo() const override { return &InstrInfo; } 73 | const Z80FrameLowering *getFrameLowering() const override { 74 | return &FrameLowering; 75 | } 76 | const Z80RegisterInfo *getRegisterInfo() const override { 77 | return &getInstrInfo()->getRegisterInfo(); 78 | } 79 | 80 | /// ParseSubtargetFeatures - Parses features string setting specified 81 | /// subtarget options. Definition of function is auto generated by tblgen. 82 | void ParseSubtargetFeatures(StringRef CPU, StringRef FS); 83 | 84 | private: 85 | Z80Subtarget &initializeSubtargetDependencies(StringRef CPU, StringRef FS); 86 | void initializeEnvironment(); 87 | public: 88 | const Triple &getTargetTriple() const { return TargetTriple; } 89 | /// Is this ez80 (disregarding specific ABI / programming model) 90 | bool is24Bit() const { return In24BitMode; } 91 | bool is16Bit() const { return In16BitMode; } 92 | bool hasUndocOps() const { return HasUndocOps; } 93 | bool hasZ180Ops() const { return HasZ180Ops; } 94 | bool hasEZ80Ops() const { return HasEZ80Ops; } 95 | bool hasIndexHalfRegs() const { return HasIdxHalfRegs; } 96 | bool has24BitEZ80Ops() const { return is24Bit() && hasEZ80Ops(); } 97 | bool has16BitEZ80Ops() const { return is16Bit() && hasEZ80Ops(); } 98 | }; 99 | } // End llvm namespace 100 | 101 | #endif 102 | -------------------------------------------------------------------------------- /tools/clang/lib/Basic/Targets/Z80.h: -------------------------------------------------------------------------------- 1 | //===--- Z80.h - Declare Z80 target feature support -------------*- C++ -*-===// 2 | // 3 | // The LLVM Compiler Infrastructure 4 | // 5 | // This file is distributed under the University of Illinois Open Source 6 | // License. See LICENSE.TXT for details. 7 | // 8 | //===----------------------------------------------------------------------===// 9 | // 10 | // This file declares Z80 TargetInfo objects. 11 | // 12 | //===----------------------------------------------------------------------===// 13 | 14 | #ifndef LLVM_CLANG_LIB_BASIC_TARGETS_Z80_H 15 | #define LLVM_CLANG_LIB_BASIC_TARGETS_Z80_H 16 | 17 | #include "Targets.h" 18 | #include "clang/Basic/TargetInfo.h" 19 | #include "llvm/Support/Compiler.h" 20 | 21 | namespace clang { 22 | namespace targets { 23 | 24 | class LLVM_LIBRARY_VISIBILITY Z80TargetInfoBase : public TargetInfo { 25 | public: 26 | Z80TargetInfoBase(const llvm::Triple &Triple) : TargetInfo(Triple) { 27 | TLSSupported = false; 28 | PointerAlign = BoolAlign = ShortAlign = IntAlign = HalfAlign = FloatAlign = 29 | DoubleAlign = LongDoubleAlign = LongAlign = LongLongAlign = 30 | SuitableAlign = MinGlobalAlign = 8; 31 | DefaultAlignForAttributeAligned = 32; 32 | SizeType = UnsignedInt; 33 | PtrDiffType = IntPtrType = SignedInt; 34 | Char32Type = UnsignedLong; 35 | UseBitFieldTypeAlignment = false; 36 | } 37 | bool hasInt48Type() const override { return true; } 38 | ArrayRef getTargetBuiltins() const final { return None; } 39 | BuiltinVaListKind getBuiltinVaListKind() const override { 40 | return TargetInfo::CharPtrBuiltinVaList; 41 | } 42 | bool validateAsmConstraint(const char *&Name, 43 | TargetInfo::ConstraintInfo &Info) const override { 44 | return false; 45 | } 46 | const char *getClobbers() const override { return ""; } 47 | void getTargetDefines(const LangOptions &Opts, 48 | MacroBuilder &Builder) const override { 49 | } 50 | }; 51 | 52 | class LLVM_LIBRARY_VISIBILITY Z80TargetInfo : public Z80TargetInfoBase { 53 | public: 54 | explicit Z80TargetInfo(const llvm::Triple &T) : Z80TargetInfoBase(T) { 55 | PointerWidth = IntWidth = 16; 56 | resetDataLayout("e-m:o-p:16:8-p1:8:8-i16:8-i24:8-i32:8-i48:8-i64:8-i96:8-f32:8-f64:8-a:8-n8:16-S8"); 57 | } 58 | 59 | private: 60 | bool setCPU(const std::string &Name) override; 61 | bool 62 | initFeatureMap(llvm::StringMap &Features, DiagnosticsEngine &Diags, 63 | StringRef CPU, 64 | const std::vector &FeaturesVec) const override; 65 | ArrayRef getGCCRegNames() const override; 66 | ArrayRef getGCCRegAliases() const override { 67 | return None; 68 | } 69 | void getTargetDefines(const LangOptions &Opts, 70 | MacroBuilder &Builder) const override; 71 | }; 72 | 73 | class LLVM_LIBRARY_VISIBILITY EZ80TargetInfo : public Z80TargetInfoBase { 74 | public: 75 | explicit EZ80TargetInfo(const llvm::Triple &T) : Z80TargetInfoBase(T) { 76 | if (T.getEnvironment() == llvm::Triple::CODE16) { 77 | PointerWidth = IntWidth = 16; 78 | resetDataLayout("e-m:o-p:16:8-p1:16:8-p2:24:8-i16:8-i24:8-i32:8-i48:8-i64:8-i96:8-f32:8-f64:8-a:8-n8:16-S8"); 79 | } else { 80 | PointerWidth = IntWidth = 24; 81 | resetDataLayout("e-m:o-p:24:8-p1:16:8-p2:16:8-i16:8-i24:8-i32:8-i48:8-i64:8-i96:8-f32:8-f64:8-a:8-n8:16:24-S8"); 82 | } 83 | } 84 | private: 85 | bool setCPU(const std::string &Name) override; 86 | ArrayRef getGCCRegNames() const override; 87 | ArrayRef getGCCRegAliases() const override; 88 | void getTargetDefines(const LangOptions &Opts, 89 | MacroBuilder &Builder) const override; 90 | }; 91 | 92 | } // namespace targets 93 | } // namespace clang 94 | 95 | #endif // LLVM_CLANG_LIB_BASIC_TARGETS_Z80_H 96 | -------------------------------------------------------------------------------- /utils/emacs/llvm-mode.el: -------------------------------------------------------------------------------- 1 | ;;; llvm-mode.el --- Major mode for the LLVM assembler language. 2 | 3 | ;; Maintainer: The LLVM team, http://llvm.org/ 4 | 5 | ;;; Commentary: 6 | 7 | ;; Major mode for editing LLVM IR files. 8 | 9 | ;;; Code: 10 | 11 | (defvar llvm-mode-syntax-table 12 | (let ((table (make-syntax-table))) 13 | (modify-syntax-entry ?% "_" table) 14 | (modify-syntax-entry ?. "_" table) 15 | (modify-syntax-entry ?\; "< " table) 16 | (modify-syntax-entry ?\n "> " table) 17 | table) 18 | "Syntax table used while in LLVM mode.") 19 | 20 | (defvar llvm-font-lock-keywords 21 | (list 22 | ;; Variables 23 | '("%[-a-zA-Z$\._][-a-zA-Z$\._0-9]*" . font-lock-variable-name-face) 24 | ;; Labels 25 | '("[-a-zA-Z$\._0-9]+:" . font-lock-variable-name-face) 26 | ;; Unnamed variable slots 27 | '("%[-]?[0-9]+" . font-lock-variable-name-face) 28 | ;; Types 29 | `(,(regexp-opt '("void" "i1" "i8" "i16" "i24" "i32" "i48" "i64" "i96" "i128" "float" "double" "type" "label" "opaque") 'symbols) . font-lock-type-face) 30 | ;; Integer literals 31 | '("\\b[-]?[0-9]+\\b" . font-lock-preprocessor-face) 32 | ;; Floating point constants 33 | '("\\b[-+]?[0-9]+\.[0-9]*\([eE][-+]?[0-9]+\)?\\b" . font-lock-preprocessor-face) 34 | ;; Hex constants 35 | '("\\b0x[0-9A-Fa-f]+\\b" . font-lock-preprocessor-face) 36 | ;; Keywords 37 | `(,(regexp-opt '("begin" "end" "true" "false" "zeroinitializer" "declare" 38 | "define" "global" "constant" "const" "internal" "linkonce" "linkonce_odr" 39 | "weak" "weak_odr" "appending" "uninitialized" "implementation" "..." 40 | "null" "undef" "to" "except" "not" "target" "endian" "little" "big" 41 | "pointersize" "volatile" "fastcc" "coldcc" "cc" "personality") 'symbols) . font-lock-keyword-face) 42 | ;; Arithmetic and Logical Operators 43 | `(,(regexp-opt '("add" "sub" "mul" "sdiv" "udiv" "urem" "srem" "and" "or" "xor" 44 | "setne" "seteq" "setlt" "setgt" "setle" "setge") 'symbols) . font-lock-keyword-face) 45 | ;; Floating-point operators 46 | `(,(regexp-opt '("fadd" "fsub" "fmul" "fdiv" "frem") 'symbols) . font-lock-keyword-face) 47 | ;; Special instructions 48 | `(,(regexp-opt '("phi" "tail" "call" "select" "to" "shl" "lshr" "ashr" "fcmp" "icmp" "va_arg" "landingpad") 'symbols) . font-lock-keyword-face) 49 | ;; Control instructions 50 | `(,(regexp-opt '("ret" "br" "switch" "invoke" "resume" "unwind" "unreachable" "indirectbr") 'symbols) . font-lock-keyword-face) 51 | ;; Memory operators 52 | `(,(regexp-opt '("malloc" "alloca" "free" "load" "store" "getelementptr" "fence" "cmpxchg" "atomicrmw") 'symbols) . font-lock-keyword-face) 53 | ;; Casts 54 | `(,(regexp-opt '("bitcast" "inttoptr" "ptrtoint" "trunc" "zext" "sext" "fptrunc" "fpext" "fptoui" "fptosi" "uitofp" "sitofp" "addrspacecast") 'symbols) . font-lock-keyword-face) 55 | ;; Vector ops 56 | `(,(regexp-opt '("extractelement" "insertelement" "shufflevector") 'symbols) . font-lock-keyword-face) 57 | ;; Aggregate ops 58 | `(,(regexp-opt '("extractvalue" "insertvalue") 'symbols) . font-lock-keyword-face) 59 | ;; Metadata types 60 | `(,(regexp-opt '("distinct") 'symbols) . font-lock-keyword-face) 61 | ;; Use-list order directives 62 | `(,(regexp-opt '("uselistorder" "uselistorder_bb") 'symbols) . font-lock-keyword-face)) 63 | "Syntax highlighting for LLVM.") 64 | 65 | ;; Emacs 23 compatibility. 66 | (defalias 'llvm-mode-prog-mode 67 | (if (fboundp 'prog-mode) 68 | 'prog-mode 69 | 'fundamental-mode)) 70 | 71 | ;;;###autoload 72 | (define-derived-mode llvm-mode llvm-mode-prog-mode "LLVM" 73 | "Major mode for editing LLVM source files. 74 | \\{llvm-mode-map} 75 | Runs `llvm-mode-hook' on startup." 76 | (setq font-lock-defaults `(llvm-font-lock-keywords)) 77 | (setq comment-start ";")) 78 | 79 | ;; Associate .ll files with llvm-mode 80 | ;;;###autoload 81 | (add-to-list 'auto-mode-alist (cons (purecopy "\\.ll\\'") 'llvm-mode)) 82 | 83 | (provide 'llvm-mode) 84 | 85 | ;;; llvm-mode.el ends here 86 | -------------------------------------------------------------------------------- /lib/Object/Binary.cpp: -------------------------------------------------------------------------------- 1 | //===- Binary.cpp - A generic binary file ---------------------------------===// 2 | // 3 | // The LLVM Compiler Infrastructure 4 | // 5 | // This file is distributed under the University of Illinois Open Source 6 | // License. See LICENSE.TXT for details. 7 | // 8 | //===----------------------------------------------------------------------===// 9 | // 10 | // This file defines the Binary class. 11 | // 12 | //===----------------------------------------------------------------------===// 13 | 14 | #include "llvm/Object/Binary.h" 15 | #include "llvm/ADT/StringRef.h" 16 | #include "llvm/BinaryFormat/Magic.h" 17 | #include "llvm/Object/Archive.h" 18 | #include "llvm/Object/Error.h" 19 | #include "llvm/Object/MachOUniversal.h" 20 | #include "llvm/Object/ObjectFile.h" 21 | #include "llvm/Object/WindowsResource.h" 22 | #include "llvm/Support/Error.h" 23 | #include "llvm/Support/ErrorHandling.h" 24 | #include "llvm/Support/ErrorOr.h" 25 | #include "llvm/Support/FileSystem.h" 26 | #include "llvm/Support/MemoryBuffer.h" 27 | #include 28 | #include 29 | #include 30 | 31 | using namespace llvm; 32 | using namespace object; 33 | 34 | Binary::~Binary() = default; 35 | 36 | Binary::Binary(unsigned int Type, MemoryBufferRef Source) 37 | : TypeID(Type), Data(Source) {} 38 | 39 | StringRef Binary::getData() const { return Data.getBuffer(); } 40 | 41 | StringRef Binary::getFileName() const { return Data.getBufferIdentifier(); } 42 | 43 | MemoryBufferRef Binary::getMemoryBufferRef() const { return Data; } 44 | 45 | Expected> object::createBinary(MemoryBufferRef Buffer, 46 | LLVMContext *Context) { 47 | file_magic Type = identify_magic(Buffer.getBuffer()); 48 | 49 | switch (Type) { 50 | case file_magic::archive: 51 | return Archive::create(Buffer); 52 | case file_magic::elf: 53 | case file_magic::elf_relocatable: 54 | case file_magic::elf_executable: 55 | case file_magic::elf_shared_object: 56 | case file_magic::elf_core: 57 | case file_magic::macho_object: 58 | case file_magic::macho_executable: 59 | case file_magic::macho_fixed_virtual_memory_shared_lib: 60 | case file_magic::macho_core: 61 | case file_magic::macho_preload_executable: 62 | case file_magic::macho_dynamically_linked_shared_lib: 63 | case file_magic::macho_dynamic_linker: 64 | case file_magic::macho_bundle: 65 | case file_magic::macho_dynamically_linked_shared_lib_stub: 66 | case file_magic::macho_dsym_companion: 67 | case file_magic::macho_kext_bundle: 68 | case file_magic::coff_object: 69 | case file_magic::coff_import_library: 70 | case file_magic::pecoff_executable: 71 | case file_magic::bitcode: 72 | case file_magic::wasm_object: 73 | case file_magic::omf_object: 74 | return ObjectFile::createSymbolicFile(Buffer, Type, Context); 75 | case file_magic::macho_universal_binary: 76 | return MachOUniversalBinary::create(Buffer); 77 | case file_magic::windows_resource: 78 | return WindowsResource::createWindowsResource(Buffer); 79 | case file_magic::unknown: 80 | case file_magic::coff_cl_gl_object: 81 | case file_magic::omf_archive: 82 | // Unrecognized object file format. 83 | return errorCodeToError(object_error::invalid_file_type); 84 | } 85 | llvm_unreachable("Unexpected Binary File Type"); 86 | } 87 | 88 | Expected> object::createBinary(StringRef Path) { 89 | ErrorOr> FileOrErr = 90 | MemoryBuffer::getFileOrSTDIN(Path); 91 | if (std::error_code EC = FileOrErr.getError()) 92 | return errorCodeToError(EC); 93 | std::unique_ptr &Buffer = FileOrErr.get(); 94 | 95 | Expected> BinOrErr = 96 | createBinary(Buffer->getMemBufferRef()); 97 | if (!BinOrErr) 98 | return BinOrErr.takeError(); 99 | std::unique_ptr &Bin = BinOrErr.get(); 100 | 101 | return OwningBinary(std::move(Bin), std::move(Buffer)); 102 | } 103 | -------------------------------------------------------------------------------- /lib/Target/Z80/Z80.td: -------------------------------------------------------------------------------- 1 | //===-- Z80.td - Target definition file for the Zilog Z80 --*- tablegen -*-===// 2 | // 3 | // The LLVM Compiler Infrastructure 4 | // 5 | // This file is distributed under the University of Illinois Open Source 6 | // License. See LICENSE.TXT for details. 7 | // 8 | //===----------------------------------------------------------------------===// 9 | // 10 | // This is a target description file for the Zilog z80 architecture, referred 11 | // to here as the "Z80" architecture. 12 | // 13 | //===----------------------------------------------------------------------===// 14 | 15 | // Get the target-independent interfaces which we are implementing... 16 | // 17 | include "llvm/Target/Target.td" 18 | 19 | //===----------------------------------------------------------------------===// 20 | // Z80 Subtarget features 21 | //===----------------------------------------------------------------------===// 22 | 23 | def FeatureUndoc : SubtargetFeature<"undoc", "HasUndocOps", "true", 24 | "Enable undocumented z80 instructions">; 25 | def FeatureZ180 : SubtargetFeature<"z180", "HasZ180Ops", "true", 26 | "Support z180 instructions">; 27 | def FeatureEZ80 : SubtargetFeature<"ez80", "HasEZ80Ops", "true", 28 | "Support ez80 instructions">; 29 | def FeatureIdxHalf : SubtargetFeature<"idxhalf", "HasIdxHalfRegs", "true", 30 | "Support index half registers">; 31 | 32 | //===----------------------------------------------------------------------===// 33 | // Z80 Subtarget state 34 | //===----------------------------------------------------------------------===// 35 | 36 | def Mode24Bit : SubtargetFeature<"24bit-mode", "In24BitMode", "true", 37 | "24-bit mode (ez80)", [FeatureEZ80]>; 38 | def Mode16Bit : SubtargetFeature<"16bit-mode", "In16BitMode", "true", 39 | "16-bit mode (z80)">; 40 | 41 | //===----------------------------------------------------------------------===// 42 | // Z80 processors supported 43 | //===----------------------------------------------------------------------===// 44 | 45 | let CompleteModel = 0 in def GenericModel : SchedMachineModel; 46 | class Proc Features> 47 | : ProcessorModel; 48 | def : Proc<"z80-generic", []>; 49 | def : Proc<"z80", [FeatureUndoc, FeatureIdxHalf]>; 50 | def : Proc<"z180", [FeatureZ180]>; 51 | def : Proc<"ez80", [FeatureZ180, FeatureEZ80, FeatureIdxHalf]>; 52 | 53 | //===----------------------------------------------------------------------===// 54 | // Register File Description 55 | //===----------------------------------------------------------------------===// 56 | 57 | include "Z80RegisterInfo.td" 58 | 59 | //===----------------------------------------------------------------------===// 60 | // Instruction Descriptions 61 | //===----------------------------------------------------------------------===// 62 | 63 | include "Z80InstrInfo.td" 64 | 65 | def Z80InstrInfo : InstrInfo; 66 | 67 | //===----------------------------------------------------------------------===// 68 | // Calling Conventions 69 | //===----------------------------------------------------------------------===// 70 | 71 | include "Z80CallingConv.td" 72 | 73 | //===----------------------------------------------------------------------===// 74 | // Assembly writer 75 | //===----------------------------------------------------------------------===// 76 | 77 | let ShouldEmitMatchRegisterName = 0 in { 78 | def Z80AsmParser : AsmParser; 79 | def EZ80AsmParser : AsmParser; 80 | } 81 | def Z80AsmWriter : AsmWriter; 82 | def EZ80AsmWriter : AsmWriter { 83 | string AsmWriterClassName = "EInstPrinter"; 84 | let Variant = 1; 85 | } 86 | 87 | def Z80 : Target { 88 | // Information about the instructions... 89 | let InstructionSet = Z80InstrInfo; 90 | let AssemblyParsers = [Z80AsmParser, EZ80AsmParser]; 91 | let AssemblyWriters = [Z80AsmWriter, EZ80AsmWriter]; 92 | } 93 | -------------------------------------------------------------------------------- /tools/clang/lib/Driver/InputInfo.h: -------------------------------------------------------------------------------- 1 | //===--- InputInfo.h - Input Source & Type Information ----------*- C++ -*-===// 2 | // 3 | // The LLVM Compiler Infrastructure 4 | // 5 | // This file is distributed under the University of Illinois Open Source 6 | // License. See LICENSE.TXT for details. 7 | // 8 | //===----------------------------------------------------------------------===// 9 | 10 | #ifndef LLVM_CLANG_LIB_DRIVER_INPUTINFO_H 11 | #define LLVM_CLANG_LIB_DRIVER_INPUTINFO_H 12 | 13 | #include "clang/Driver/Action.h" 14 | #include "clang/Driver/Types.h" 15 | #include "llvm/Option/Arg.h" 16 | #include 17 | #include 18 | 19 | namespace clang { 20 | namespace driver { 21 | 22 | /// InputInfo - Wrapper for information about an input source. 23 | class InputInfo { 24 | // FIXME: The distinction between filenames and inputarg here is 25 | // gross; we should probably drop the idea of a "linker 26 | // input". Doing so means tweaking pipelining to still create link 27 | // steps when it sees linker inputs (but not treat them as 28 | // arguments), and making sure that arguments get rendered 29 | // correctly. 30 | enum Class { 31 | Nothing, 32 | Filename, 33 | InputArg, 34 | Pipe 35 | }; 36 | 37 | union { 38 | const char *Filename; 39 | const llvm::opt::Arg *InputArg; 40 | } Data; 41 | Class Kind; 42 | const Action* Act; 43 | types::ID Type; 44 | const char *BaseInput; 45 | 46 | static types::ID GetActionType(const Action *A) { 47 | return A != nullptr ? A->getType() : types::TY_Nothing; 48 | } 49 | 50 | public: 51 | InputInfo() : InputInfo(nullptr, nullptr) {} 52 | InputInfo(const Action *A, const char *_BaseInput) 53 | : Kind(Nothing), Act(A), Type(GetActionType(A)), BaseInput(_BaseInput) {} 54 | 55 | InputInfo(types::ID _Type, const char *_Filename, const char *_BaseInput) 56 | : Kind(Filename), Act(nullptr), Type(_Type), BaseInput(_BaseInput) { 57 | Data.Filename = _Filename; 58 | } 59 | InputInfo(const Action *A, const char *_Filename, const char *_BaseInput) 60 | : Kind(Filename), Act(A), Type(GetActionType(A)), BaseInput(_BaseInput) { 61 | Data.Filename = _Filename; 62 | } 63 | 64 | InputInfo(types::ID _Type, const llvm::opt::Arg *_InputArg, 65 | const char *_BaseInput) 66 | : Kind(InputArg), Act(nullptr), Type(_Type), BaseInput(_BaseInput) { 67 | Data.InputArg = _InputArg; 68 | } 69 | InputInfo(const Action *A, const llvm::opt::Arg *_InputArg, 70 | const char *_BaseInput) 71 | : Kind(InputArg), Act(A), Type(GetActionType(A)), BaseInput(_BaseInput) { 72 | Data.InputArg = _InputArg; 73 | } 74 | 75 | bool isNothing() const { return Kind == Nothing; } 76 | bool isFilename() const { return Kind == Filename; } 77 | bool isInputArg() const { return Kind == InputArg; } 78 | types::ID getType() const { return Type; } 79 | const char *getBaseInput() const { return BaseInput; } 80 | /// The action for which this InputInfo was created. May be null. 81 | const Action *getAction() const { return Act; } 82 | void setAction(const Action *A) { Act = A; } 83 | 84 | const char *getFilename() const { 85 | assert(isFilename() && "Invalid accessor."); 86 | return Data.Filename; 87 | } 88 | const llvm::opt::Arg &getInputArg() const { 89 | assert(isInputArg() && "Invalid accessor."); 90 | return *Data.InputArg; 91 | } 92 | 93 | void setNothing() { 94 | Kind = Nothing; 95 | } 96 | void setFilename(const char *F) { 97 | Kind = Filename; 98 | Data.Filename = F; 99 | } 100 | void setInputArg(const llvm::opt::Arg *IA) { 101 | Kind = InputArg; 102 | Data.InputArg = IA; 103 | } 104 | 105 | /// getAsString - Return a string name for this input, for 106 | /// debugging. 107 | std::string getAsString() const { 108 | if (isFilename()) 109 | return std::string("\"") + getFilename() + '"'; 110 | else if (isInputArg()) 111 | return "(input arg)"; 112 | else 113 | return "(nothing)"; 114 | } 115 | }; 116 | 117 | } // end namespace driver 118 | } // end namespace clang 119 | 120 | #endif 121 | -------------------------------------------------------------------------------- /lib/Target/Z80/Z80AsmPrinter.cpp: -------------------------------------------------------------------------------- 1 | //===-- Z80AsmPrinter.cpp - Convert Z80 LLVM code to AT&T assembly --------===// 2 | // 3 | // The LLVM Compiler Infrastructure 4 | // 5 | // This file is distributed under the University of Illinois Open Source 6 | // License. See LICENSE.TXT for details. 7 | // 8 | //===----------------------------------------------------------------------===// 9 | // 10 | // This file contains a printer that converts from our internal representation 11 | // of machine-dependent LLVM code to Z80 machine code. 12 | // 13 | //===----------------------------------------------------------------------===// 14 | 15 | #include "Z80AsmPrinter.h" 16 | #include "Z80.h" 17 | #include "MCTargetDesc/Z80TargetStreamer.h" 18 | #include "llvm/CodeGen/TargetLoweringObjectFile.h" 19 | #include "llvm/MC/MCContext.h" 20 | #include "llvm/MC/MCStreamer.h" 21 | #include "llvm/Support/TargetRegistry.h" 22 | using namespace llvm; 23 | 24 | //===----------------------------------------------------------------------===// 25 | // Target Registry Stuff 26 | //===----------------------------------------------------------------------===// 27 | 28 | static bool isCode16(const Triple &TT) { 29 | return TT.getEnvironment() == Triple::CODE16; 30 | } 31 | 32 | void Z80AsmPrinter::EmitStartOfAsmFile(Module &M) { 33 | const Triple &TT = TM.getTargetTriple(); 34 | if (TT.getArch() == Triple::ez80) 35 | OutStreamer->EmitAssemblerFlag(isCode16(TT) ? MCAF_Code16 : MCAF_Code24); 36 | } 37 | 38 | void Z80AsmPrinter::emitInlineAsmEnd(const MCSubtargetInfo &StartInfo, 39 | const MCSubtargetInfo *EndInfo) const { 40 | if (TM.getTargetTriple().getArch() != Triple::ez80) 41 | return; 42 | bool Was16 = isCode16(StartInfo.getTargetTriple()); 43 | if (!EndInfo || Was16 != isCode16(EndInfo->getTargetTriple())) 44 | OutStreamer->EmitAssemblerFlag(Was16 ? MCAF_Code16 : MCAF_Code24); 45 | } 46 | 47 | void Z80AsmPrinter::EmitEndOfAsmFile(Module &M) { 48 | Z80TargetStreamer *TS = 49 | static_cast(OutStreamer->getTargetStreamer()); 50 | for (const auto &Symbol : OutContext.getSymbols()) 51 | if (!Symbol.second->isDefined()) 52 | TS->emitExtern(Symbol.second); 53 | } 54 | 55 | void Z80AsmPrinter::EmitGlobalVariable(const GlobalVariable *GV) { 56 | Z80TargetStreamer *TS = 57 | static_cast(OutStreamer->getTargetStreamer()); 58 | 59 | if (GV->hasInitializer()) { 60 | // Check to see if this is a special global used by LLVM, if so, emit it. 61 | if (EmitSpecialLLVMGlobal(GV)) 62 | return; 63 | } 64 | 65 | MCSymbol *GVSym = getSymbol(GV); 66 | 67 | if (!GV->hasInitializer()) // External globals require no extra code. 68 | return; 69 | 70 | GVSym->redefineIfPossible(); 71 | if (GVSym->isDefined() || GVSym->isVariable()) 72 | report_fatal_error("symbol '" + Twine(GVSym->getName()) + 73 | "' is already defined"); 74 | 75 | SectionKind GVKind = TargetLoweringObjectFile::getKindForGlobal(GV, TM); 76 | 77 | const DataLayout &DL = GV->getParent()->getDataLayout(); 78 | uint64_t Size = DL.getTypeAllocSize(GV->getType()->getElementType()); 79 | 80 | // If the alignment is specified, we *must* obey it. Overaligning a global 81 | // with a specified alignment is a prompt way to break globals emitted to 82 | // sections and expected to be contiguous (e.g. ObjC metadata). 83 | unsigned Align = DL.getPreferredAlignment(GV); 84 | 85 | // Determine to which section this global should be emitted. 86 | MCSection *TheSection = getObjFileLowering().SectionForGlobal(GV, GVKind, TM); 87 | 88 | OutStreamer->SwitchSection(TheSection); 89 | TS->emitAlign(Align); 90 | if (!GV->hasLocalLinkage()) 91 | TS->emitGlobal(GVSym); 92 | OutStreamer->EmitLabel(GVSym); 93 | if (GVKind.isBSS()) 94 | TS->emitBlock(Size); 95 | else 96 | EmitGlobalConstant(DL, GV->getInitializer()); 97 | OutStreamer->AddBlankLine(); 98 | } 99 | 100 | // Force static initialization. 101 | extern "C" void LLVMInitializeZ80AsmPrinter() { 102 | RegisterAsmPrinter X(getTheZ80Target()); 103 | RegisterAsmPrinter Y(getTheEZ80Target()); 104 | } 105 | -------------------------------------------------------------------------------- /tools/llvm-readobj/ObjDumper.h: -------------------------------------------------------------------------------- 1 | //===-- ObjDumper.h ---------------------------------------------*- C++ -*-===// 2 | // 3 | // The LLVM Compiler Infrastructure 4 | // 5 | // This file is distributed under the University of Illinois Open Source 6 | // License. See LICENSE.TXT for details. 7 | // 8 | //===----------------------------------------------------------------------===// 9 | 10 | #ifndef LLVM_TOOLS_LLVM_READOBJ_OBJDUMPER_H 11 | #define LLVM_TOOLS_LLVM_READOBJ_OBJDUMPER_H 12 | 13 | #include 14 | #include 15 | 16 | namespace llvm { 17 | namespace object { 18 | class COFFImportFile; 19 | class ObjectFile; 20 | } 21 | namespace codeview { 22 | class TypeTableBuilder; 23 | } 24 | 25 | class ScopedPrinter; 26 | 27 | class ObjDumper { 28 | public: 29 | ObjDumper(ScopedPrinter &Writer); 30 | virtual ~ObjDumper(); 31 | 32 | virtual void printFileHeaders() = 0; 33 | virtual void printSections() = 0; 34 | virtual void printRelocations() = 0; 35 | virtual void printSymbols() = 0; 36 | virtual void printDynamicSymbols() = 0; 37 | virtual void printUnwindInfo() = 0; 38 | 39 | // Only implemented for ELF at this time. 40 | virtual void printDynamicRelocations() { } 41 | virtual void printDynamicTable() { } 42 | virtual void printNeededLibraries() { } 43 | virtual void printProgramHeaders() { } 44 | virtual void printHashTable() { } 45 | virtual void printGnuHashTable() { } 46 | virtual void printLoadName() {} 47 | virtual void printVersionInfo() {} 48 | virtual void printGroupSections() {} 49 | virtual void printHashHistogram() {} 50 | virtual void printNotes() {} 51 | 52 | // Only implemented for ARM ELF at this time. 53 | virtual void printAttributes() { } 54 | 55 | // Only implemented for MIPS ELF at this time. 56 | virtual void printMipsPLTGOT() { } 57 | virtual void printMipsABIFlags() { } 58 | virtual void printMipsReginfo() { } 59 | virtual void printMipsOptions() { } 60 | 61 | // Only implemented for PE/COFF. 62 | virtual void printCOFFImports() { } 63 | virtual void printCOFFExports() { } 64 | virtual void printCOFFDirectives() { } 65 | virtual void printCOFFBaseReloc() { } 66 | virtual void printCOFFDebugDirectory() { } 67 | virtual void printCOFFResources() {} 68 | virtual void printCOFFLoadConfig() { } 69 | virtual void printCodeViewDebugInfo() { } 70 | virtual void mergeCodeViewTypes(llvm::codeview::TypeTableBuilder &CVIDs, 71 | llvm::codeview::TypeTableBuilder &CVTypes) {} 72 | 73 | // Only implemented for MachO. 74 | virtual void printMachODataInCode() { } 75 | virtual void printMachOVersionMin() { } 76 | virtual void printMachODysymtab() { } 77 | virtual void printMachOSegment() { } 78 | virtual void printMachOIndirectSymbols() { } 79 | virtual void printMachOLinkerOptions() { } 80 | 81 | virtual void printStackMap() const = 0; 82 | 83 | protected: 84 | ScopedPrinter &W; 85 | }; 86 | 87 | std::error_code createCOFFDumper(const object::ObjectFile *Obj, 88 | ScopedPrinter &Writer, 89 | std::unique_ptr &Result); 90 | 91 | std::error_code createELFDumper(const object::ObjectFile *Obj, 92 | ScopedPrinter &Writer, 93 | std::unique_ptr &Result); 94 | 95 | std::error_code createMachODumper(const object::ObjectFile *Obj, 96 | ScopedPrinter &Writer, 97 | std::unique_ptr &Result); 98 | 99 | std::error_code createOMFDumper(const object::ObjectFile *Obj, 100 | ScopedPrinter &Writer, 101 | std::unique_ptr &Result); 102 | 103 | std::error_code createWasmDumper(const object::ObjectFile *Obj, 104 | ScopedPrinter &Writer, 105 | std::unique_ptr &Result); 106 | 107 | void dumpCOFFImportFile(const object::COFFImportFile *File); 108 | 109 | void dumpCodeViewMergedTypes(ScopedPrinter &Writer, 110 | llvm::codeview::TypeTableBuilder &IDTable, 111 | llvm::codeview::TypeTableBuilder &TypeTable); 112 | 113 | } // namespace llvm 114 | 115 | #endif 116 | -------------------------------------------------------------------------------- /include/llvm/Object/OMFObjectFile.h: -------------------------------------------------------------------------------- 1 | //===- OMFObjectFile.h - OMF object file implementation ---------*- C++ -*-===// 2 | // 3 | // The LLVM Compiler Infrastructure 4 | // 5 | // This file is distributed under the University of Illinois Open Source 6 | // License. See LICENSE.TXT for details. 7 | // 8 | //===----------------------------------------------------------------------===// 9 | // 10 | // This file declares the OMFObjectFile class, which implements the ObjectFile 11 | // interface for OMF files. 12 | // 13 | //===----------------------------------------------------------------------===// 14 | 15 | #ifndef LLVM_OBJECT_OMFOBJECTFILE_H 16 | #define LLVM_OBJECT_OMFOBJECTFILE_H 17 | 18 | #include "llvm/Object/OMF.h" 19 | 20 | namespace llvm { 21 | namespace object { 22 | 23 | class OMFObjectFile : public ObjectFile { 24 | public: 25 | OMFObjectFile(MemoryBufferRef Object, Error &EC); 26 | 27 | static inline bool classof(const Binary *v) { return v->isOMF(); } 28 | 29 | protected: 30 | // Overrides from SymbolRef. 31 | void moveSymbolNext(DataRefImpl &Symb) const override; 32 | uint32_t getSymbolFlags(DataRefImpl Symb) const override; 33 | basic_symbol_iterator symbol_begin() const override; 34 | basic_symbol_iterator symbol_end() const override; 35 | Expected getSymbolName(DataRefImpl Symb) const override; 36 | Expected getSymbolAddress(DataRefImpl Symb) const override; 37 | uint64_t getSymbolValueImpl(DataRefImpl Symb) const override; 38 | uint32_t getSymbolAlignment(DataRefImpl Symb) const override; 39 | uint64_t getCommonSymbolSizeImpl(DataRefImpl Symb) const override; 40 | Expected getSymbolType(DataRefImpl Symb) const override; 41 | Expected 42 | getSymbolSection(DataRefImpl Symb) const override; 43 | 44 | // Overrides from SectionRef. 45 | void moveSectionNext(DataRefImpl &Sec) const override; 46 | std::error_code getSectionName(DataRefImpl Sec, 47 | StringRef &Res) const override; 48 | uint64_t getSectionAddress(DataRefImpl Sec) const override; 49 | uint64_t getSectionIndex(DataRefImpl Sec) const override; 50 | uint64_t getSectionSize(DataRefImpl Sec) const override; 51 | std::error_code getSectionContents(DataRefImpl Sec, 52 | StringRef &Res) const override; 53 | uint64_t getSectionAlignment(DataRefImpl Sec) const override; 54 | bool isSectionCompressed(DataRefImpl Sec) const override; 55 | bool isSectionText(DataRefImpl Sec) const override; 56 | bool isSectionData(DataRefImpl Sec) const override; 57 | bool isSectionBSS(DataRefImpl Sec) const override; 58 | bool isSectionVirtual(DataRefImpl Sec) const override; 59 | section_iterator section_begin() const override; 60 | section_iterator section_end() const override; 61 | relocation_iterator section_rel_begin(DataRefImpl Sec) const override; 62 | relocation_iterator section_rel_end(DataRefImpl Sec) const override; 63 | 64 | // Same as above for RelocationRef. 65 | void moveRelocationNext(DataRefImpl &Rel) const override; 66 | uint64_t getRelocationOffset(DataRefImpl Rel) const override; 67 | symbol_iterator getRelocationSymbol(DataRefImpl Rel) const override; 68 | uint64_t getRelocationType(DataRefImpl Rel) const override; 69 | void getRelocationTypeName(DataRefImpl Rel, 70 | SmallVectorImpl &Result) const override; 71 | 72 | public: 73 | uint8_t getBytesInAddress() const override; 74 | StringRef getFileFormatName() const override; 75 | /* Triple::ArchType */ unsigned getArch() const override; 76 | StringRef getProcessor() const; 77 | StringRef getModuleName() const; 78 | uint64_t getMAUBits() const; 79 | uint64_t getAddrMAUs() const; 80 | SubtargetFeatures getFeatures() const override; 81 | bool isRelocatableObject() const override; 82 | StringRef getSectionType(const SectionRef &Sec) const; 83 | 84 | private: 85 | Error parse(); 86 | 87 | std::string FileFormatName = "OMF-"; 88 | StringRef ModuleName; 89 | uint64_t MAUBits = 8, AddrMAUs = 4; 90 | support::endianness Endianness = support::big; 91 | std::vector Contexts; 92 | std::vector Sections; 93 | std::vector Symbols; 94 | }; 95 | 96 | } // end namespace object 97 | } // end namespace llvm 98 | 99 | #endif // LLVM_OBJECT_OMFOBJECTFILE_H 100 | -------------------------------------------------------------------------------- /lib/Target/Z80/Z80RegisterInfo.td: -------------------------------------------------------------------------------- 1 | //===- Z80RegisterInfo.td - Describe the Z80 Register File --*- tablegen -*-==// 2 | // 3 | // The LLVM Compiler Infrastructure 4 | // 5 | // This file is distributed under the University of Illinois Open Source 6 | // License. See LICENSE.TXT for details. 7 | // 8 | //===----------------------------------------------------------------------===// 9 | // 10 | // This file describes the Z80 Register file, defining the registers themselves, 11 | // aliases between the registers, and the register classes built out of the 12 | // registers. 13 | // 14 | //===----------------------------------------------------------------------===// 15 | 16 | class Z80Reg Enc = -1> : Register { 17 | let Namespace = "Z80"; 18 | let HWEncoding = Enc; 19 | } 20 | class Z80RegWithSubRegs sub = [], bits<16> enc = -1> 21 | : Z80Reg { 22 | let SubRegs = sub; 23 | } 24 | 25 | // Subregister indices. 26 | let Namespace = "Z80" in { 27 | def sub_low : SubRegIndex<8>; 28 | def sub_high : SubRegIndex<8, 8>; 29 | def sub_short : SubRegIndex<16>; 30 | } 31 | 32 | //===----------------------------------------------------------------------===// 33 | // Register definitions... 34 | // 35 | 36 | // 8-bit registers 37 | def A : Z80Reg<"a", 7>; 38 | def F : Z80Reg<"f">; 39 | def B : Z80Reg<"b", 0>; 40 | def C : Z80Reg<"c", 1>; 41 | def D : Z80Reg<"d", 2>; 42 | def E : Z80Reg<"e", 3>; 43 | def H : Z80Reg<"h", 4>; 44 | def L : Z80Reg<"l", 5>; 45 | 46 | // 8-bit index registers 47 | let CostPerUse = 1 in { 48 | def IXH : Z80Reg<"ixh", 4>; 49 | def IXL : Z80Reg<"ixl", 5>; 50 | def IYH : Z80Reg<"iyh", 4>; 51 | def IYL : Z80Reg<"iyl", 5>; 52 | } 53 | 54 | let SubRegIndices = [sub_high, sub_low], CoveredBySubRegs = 1 in { 55 | // 16-bit registers 56 | def AF : Z80RegWithSubRegs<"af", [A,F], 3>; 57 | def BC : Z80RegWithSubRegs<"bc", [B,C], 0>; 58 | def DE : Z80RegWithSubRegs<"de", [D,E], 1>; 59 | def HL : Z80RegWithSubRegs<"hl", [H,L], 2>; 60 | // 16-bit index registers 61 | let CostPerUse = 1 in { 62 | def IX : Z80RegWithSubRegs<"ix", [IXH,IXL], 2>; 63 | def IY : Z80RegWithSubRegs<"iy", [IYH,IYL], 2>; 64 | } 65 | } 66 | def SPS : Z80Reg<"sp", 3>; 67 | 68 | let SubRegIndices = [sub_short] in { 69 | // 24-bit registers 70 | def UBC : Z80RegWithSubRegs<"bc", [BC], 0>; 71 | def UDE : Z80RegWithSubRegs<"de", [DE], 1>; 72 | def UHL : Z80RegWithSubRegs<"hl", [HL], 2>; 73 | // 24-bit index registers 74 | let CostPerUse = 1 in { 75 | def UIX : Z80RegWithSubRegs<"ix", [IX], 2>; 76 | def UIY : Z80RegWithSubRegs<"iy", [IY], 2>; 77 | } 78 | } 79 | def SPL : Z80Reg<"sp", 3>; 80 | def PC : Z80Reg<"pc">; 81 | 82 | //===----------------------------------------------------------------------===// 83 | // Register Class Definitions... 84 | // 85 | 86 | class Z80RC8 : RegisterClass<"Z80", [i8 ], 8, regList>; 87 | class Z80RC16 : RegisterClass<"Z80", [i16], 8, regList>; 88 | class Z80RC24 : RegisterClass<"Z80", [i24], 8, regList>; 89 | 90 | let CopyCost = -1, isAllocatable = 0 in 91 | def F8 : Z80RC8 <(add F)>; 92 | def G8 : Z80RC8 <(add A, L, E, C, H, D, B)>; 93 | def O8 : Z80RC8 <(add A, E, C, D, B)>; 94 | def Y8 : Z80RC8 <(add O8, IYL, IYH)>; 95 | def X8 : Z80RC8 <(add O8, IXL, IXH)>; 96 | def I8 : Z80RC8 <(add IYL, IYH, IXL, IXH)>; 97 | def R8 : Z80RC8 <(add G8, I8)>; 98 | 99 | def O16 : Z80RC16<(add DE, BC)>; 100 | def G16 : Z80RC16<(add HL, O16)>; 101 | def Y16 : Z80RC16<(add IY, O16)>; 102 | def X16 : Z80RC16<(add IX, O16)>; 103 | def I16 : Z80RC16<(add IY, IX)>; 104 | def A16 : Z80RC16<(add HL, I16)>; 105 | def R16 : Z80RC16<(add G16, I16)>; 106 | def Z16 : Z80RC16<(add SPS, AF)>; 107 | //def S16 : Z80RC16<(add R16, AF)>; 108 | //def L16 : Z80RC16<(add G16, I16)>; 109 | //def R16 : Z80RC16<(add L16, SPS)>; 110 | //def S16 : Z80RC16<(add L16, AF)>; 111 | //def C16 : Z80RC16<(add R16, SPS)>; 112 | 113 | def O24 : Z80RC24<(add UDE, UBC)>; 114 | def G24 : Z80RC24<(add UHL, O24)>; 115 | def Y24 : Z80RC24<(add UIY, O24)>; 116 | def X24 : Z80RC24<(add UIX, O24)>; 117 | def I24 : Z80RC24<(add UIY, UIX)>; 118 | def A24 : Z80RC24<(add UHL, I24)>; 119 | def R24 : Z80RC24<(add G24, I24)>; 120 | def Z24 : Z80RC24<(add SPL)>; 121 | //def S24 : Z80RC24<(add R24, AF)>; 122 | //def L24 : Z80RC24<(add G24, I24)>; 123 | //def R24 : Z80RC24<(add L24, SPL)>; 124 | //def S24 : Z80RC24<(add L24, AF)>; 125 | //def C24 : Z80RC24<(add R24, SPL)>; 126 | -------------------------------------------------------------------------------- /lib/Target/Z80/Z80MCInstLower.cpp: -------------------------------------------------------------------------------- 1 | //===-- Z80MCInstLower.cpp - Convert Z80 MachineInstr to an MCInst --------===// 2 | // 3 | // The LLVM Compiler Infrastructure 4 | // 5 | // This file is distributed under the University of Illinois Open Source 6 | // License. See LICENSE.TXT for details. 7 | // 8 | //===----------------------------------------------------------------------===// 9 | // 10 | // This file contains code to lower Z80 MachineInstrs to their corresponding 11 | // MCInst records. 12 | // 13 | //===----------------------------------------------------------------------===// 14 | 15 | #include "Z80AsmPrinter.h" 16 | #include "llvm/IR/Mangler.h" 17 | #include "llvm/MC/MCContext.h" 18 | #include "llvm/MC/MCInst.h" 19 | #include "llvm/MC/MCStreamer.h" 20 | using namespace llvm; 21 | 22 | #define DEBUG_TYPE "z80-mclower" 23 | 24 | namespace { 25 | /// Z80MCInstLower - This class is used to lower a MachineInstr into an MCInst. 26 | class Z80MCInstLower { 27 | MCContext &Ctx; 28 | const MachineFunction &Func; 29 | Z80AsmPrinter &AsmPrinter; 30 | 31 | public: 32 | Z80MCInstLower(const MachineFunction &MF, Z80AsmPrinter &AP); 33 | 34 | Optional LowerMachineOperand(const MachineInstr *MI, 35 | const MachineOperand &MO) const; 36 | 37 | MCSymbol *GetGlobalAddressSymbol(const MachineOperand &MO) const; 38 | MCSymbol *GetExternalSymbolSymbol(const MachineOperand &MO) const; 39 | MCOperand LowerSymbolOperand(const MachineOperand &MO, MCSymbol *Sym) const; 40 | 41 | void Lower(const MachineInstr *MI, MCInst &OutMI) const; 42 | }; 43 | } 44 | 45 | Z80MCInstLower::Z80MCInstLower(const MachineFunction &MF, Z80AsmPrinter &AP) 46 | : Ctx(MF.getContext()), Func(MF), AsmPrinter(AP) {} 47 | 48 | /// GetGlobalAddressSymbol - Lower an MO_GlobalAddress operand to an MCSymbol. 49 | MCSymbol * 50 | Z80MCInstLower::GetGlobalAddressSymbol(const MachineOperand &MO) const { 51 | assert(!MO.getTargetFlags() && "Unknown target flag on GV operand"); 52 | return AsmPrinter.getSymbol(MO.getGlobal()); 53 | } 54 | 55 | /// GetExternalSymbolSymbol - Lower an MO_ExternalSymbol operand to an MCSymbol. 56 | MCSymbol * 57 | Z80MCInstLower::GetExternalSymbolSymbol(const MachineOperand &MO) const { 58 | assert(!MO.getTargetFlags() && "Unknown target flag on GV operand"); 59 | return AsmPrinter.GetExternalSymbolSymbol(MO.getSymbolName()); 60 | } 61 | 62 | MCOperand Z80MCInstLower::LowerSymbolOperand(const MachineOperand &MO, 63 | MCSymbol *Sym) const { 64 | assert(!MO.getTargetFlags() && "Unknown target flag on GV operand"); 65 | const MCExpr *Expr = MCSymbolRefExpr::create(Sym, Ctx); 66 | if (auto Off = MO.getOffset()) 67 | Expr = MCBinaryExpr::createAdd(Expr, MCConstantExpr::create(Off, Ctx), Ctx); 68 | return MCOperand::createExpr(Expr); 69 | } 70 | 71 | Optional 72 | Z80MCInstLower::LowerMachineOperand(const MachineInstr *MI, 73 | const MachineOperand &MO) const { 74 | switch (MO.getType()) { 75 | default: 76 | DEBUG(MI->dump()); 77 | llvm_unreachable("unknown operand type"); 78 | case MachineOperand::MO_Register: 79 | return MCOperand::createReg(MO.getReg()); 80 | case MachineOperand::MO_Immediate: 81 | return MCOperand::createImm(MO.getImm()); 82 | case MachineOperand::MO_MachineBasicBlock: 83 | return MCOperand::createExpr(MCSymbolRefExpr::create( 84 | MO.getMBB()->getSymbol(), Ctx)); 85 | case MachineOperand::MO_GlobalAddress: 86 | return LowerSymbolOperand(MO, GetGlobalAddressSymbol(MO)); 87 | case MachineOperand::MO_ExternalSymbol: 88 | return LowerSymbolOperand(MO, GetExternalSymbolSymbol(MO)); 89 | case MachineOperand::MO_RegisterMask: 90 | return None; // Ignore call clobbers. 91 | } 92 | } 93 | 94 | void Z80MCInstLower::Lower(const MachineInstr *MI, MCInst &OutMI) const { 95 | OutMI.setOpcode(MI->getOpcode()); 96 | 97 | MCOperand MCOp; 98 | for (const MachineOperand &MO : MI->operands()) 99 | if (auto PossibleMCOp = LowerMachineOperand(MI, MO)) 100 | OutMI.addOperand(*PossibleMCOp); 101 | } 102 | 103 | void Z80AsmPrinter::EmitInstruction(const MachineInstr *MI) { 104 | Z80MCInstLower MCInstLowering(*MF, *this); 105 | 106 | MCInst TmpInst; 107 | MCInstLowering.Lower(MI, TmpInst); 108 | EmitToStreamer(*OutStreamer, TmpInst); 109 | } 110 | -------------------------------------------------------------------------------- /lib/MC/MCAsmInfo.cpp: -------------------------------------------------------------------------------- 1 | //===- MCAsmInfo.cpp - Asm Info -------------------------------------------===// 2 | // 3 | // The LLVM Compiler Infrastructure 4 | // 5 | // This file is distributed under the University of Illinois Open Source 6 | // License. See LICENSE.TXT for details. 7 | // 8 | //===----------------------------------------------------------------------===// 9 | // 10 | // This file defines target asm properties related what form asm statements 11 | // should take. 12 | // 13 | //===----------------------------------------------------------------------===// 14 | 15 | #include "llvm/MC/MCAsmInfo.h" 16 | #include "llvm/BinaryFormat/Dwarf.h" 17 | #include "llvm/MC/MCContext.h" 18 | #include "llvm/MC/MCExpr.h" 19 | #include "llvm/MC/MCStreamer.h" 20 | 21 | using namespace llvm; 22 | 23 | MCAsmInfo::MCAsmInfo() { 24 | SeparatorString = ";"; 25 | CommentString = "#"; 26 | LabelSuffix = ":"; 27 | PrivateGlobalPrefix = "L"; 28 | PrivateLabelPrefix = PrivateGlobalPrefix; 29 | LinkerPrivateGlobalPrefix = ""; 30 | InlineAsmStart = "APP"; 31 | InlineAsmEnd = "NO_APP"; 32 | Code16Directive = ".code16"; 33 | Code24Directive = nullptr; 34 | Code32Directive = ".code32"; 35 | Code64Directive = ".code64"; 36 | ZeroDirective = "\t.zero\t"; 37 | AsciiDirective = "\t.ascii\t"; 38 | AscizDirective = "\t.asciz\t"; 39 | Data8bitsDirective = "\t.byte\t"; 40 | Data16bitsDirective = "\t.short\t"; 41 | Data24bitsDirective = nullptr; 42 | Data32bitsDirective = "\t.long\t"; 43 | Data64bitsDirective = "\t.quad\t"; 44 | AssignmentDirective = " = "; 45 | GlobalDirective = "\t.globl\t"; 46 | WeakDirective = "\t.weak\t"; 47 | 48 | // FIXME: Clang's logic should be synced with the logic used to initialize 49 | // this member and the two implementations should be merged. 50 | // For reference: 51 | // - Solaris always enables the integrated assembler by default 52 | // - SparcELFMCAsmInfo and X86ELFMCAsmInfo are handling this case 53 | // - Windows always enables the integrated assembler by default 54 | // - MCAsmInfoCOFF is handling this case, should it be MCAsmInfoMicrosoft? 55 | // - MachO targets always enables the integrated assembler by default 56 | // - MCAsmInfoDarwin is handling this case 57 | // - Generic_GCC toolchains enable the integrated assembler on a per 58 | // architecture basis. 59 | // - The target subclasses for AArch64, ARM, and X86 handle these cases 60 | UseIntegratedAssembler = false; 61 | PreserveAsmComments = true; 62 | } 63 | 64 | MCAsmInfo::~MCAsmInfo() = default; 65 | 66 | bool MCAsmInfo::isSectionAtomizableBySymbols(const MCSection &Section) const { 67 | return false; 68 | } 69 | 70 | const MCExpr * 71 | MCAsmInfo::getExprForPersonalitySymbol(const MCSymbol *Sym, 72 | unsigned Encoding, 73 | MCStreamer &Streamer) const { 74 | return getExprForFDESymbol(Sym, Encoding, Streamer); 75 | } 76 | 77 | const MCExpr * 78 | MCAsmInfo::getExprForFDESymbol(const MCSymbol *Sym, 79 | unsigned Encoding, 80 | MCStreamer &Streamer) const { 81 | if (!(Encoding & dwarf::DW_EH_PE_pcrel)) 82 | return MCSymbolRefExpr::create(Sym, Streamer.getContext()); 83 | 84 | MCContext &Context = Streamer.getContext(); 85 | const MCExpr *Res = MCSymbolRefExpr::create(Sym, Context); 86 | MCSymbol *PCSym = Context.createTempSymbol(); 87 | Streamer.EmitLabel(PCSym); 88 | const MCExpr *PC = MCSymbolRefExpr::create(PCSym, Context); 89 | return MCBinaryExpr::createSub(Res, PC, Context); 90 | } 91 | 92 | static bool isAcceptableChar(char C) { 93 | return (C >= 'a' && C <= 'z') || (C >= 'A' && C <= 'Z') || 94 | (C >= '0' && C <= '9') || C == '_' || C == '$' || C == '.' || C == '@'; 95 | } 96 | 97 | bool MCAsmInfo::isValidUnquotedName(StringRef Name) const { 98 | if (Name.empty()) 99 | return false; 100 | 101 | // If any of the characters in the string is an unacceptable character, force 102 | // quotes. 103 | for (char C : Name) { 104 | if (!isAcceptableChar(C)) 105 | return false; 106 | } 107 | 108 | return true; 109 | } 110 | 111 | bool MCAsmInfo::shouldOmitSectionDirective(StringRef SectionName) const { 112 | // FIXME: Does .section .bss/.data/.text work everywhere?? 113 | return SectionName == ".text" || SectionName == ".data" || 114 | (SectionName == ".bss" && !usesELFSectionDirectiveForBSS()); 115 | } 116 | -------------------------------------------------------------------------------- /lib/Target/Z80/MCTargetDesc/Z80MCTargetDesc.cpp: -------------------------------------------------------------------------------- 1 | //===-- Z80MCTargetDesc.cpp - Z80 Target Descriptions ---------------------===// 2 | // 3 | // The LLVM Compiler Infrastructure 4 | // 5 | // This file is distributed under the University of Illinois Open Source 6 | // License. See LICENSE.TXT for details. 7 | // 8 | //===----------------------------------------------------------------------===// 9 | // 10 | // This file provides Z80 specific target descriptions. 11 | // 12 | //===----------------------------------------------------------------------===// 13 | 14 | #include "Z80MCTargetDesc.h" 15 | #include "InstPrinter/Z80InstPrinter.h" 16 | #include "InstPrinter/EZ80InstPrinter.h" 17 | #include "Z80MCAsmInfo.h" 18 | #include "Z80TargetStreamer.h" 19 | #include "llvm/MC/MCInstrInfo.h" 20 | #include "llvm/MC/MCRegisterInfo.h" 21 | #include "llvm/MC/MCSubtargetInfo.h" 22 | #include "llvm/Support/TargetRegistry.h" 23 | using namespace llvm; 24 | 25 | #define GET_REGINFO_MC_DESC 26 | #include "Z80GenRegisterInfo.inc" 27 | 28 | #define GET_INSTRINFO_MC_DESC 29 | #include "Z80GenInstrInfo.inc" 30 | 31 | #define GET_SUBTARGETINFO_MC_DESC 32 | #include "Z80GenSubtargetInfo.inc" 33 | 34 | std::string Z80_MC::ParseZ80Triple(const Triple &TT) { 35 | std::string FS; 36 | if (TT.getArch() == Triple::ez80) 37 | FS = "+24bit-mode,-16bit-mode"; 38 | else 39 | FS = "-24bit-mode,+16bit-mode"; 40 | 41 | return FS; 42 | } 43 | 44 | MCSubtargetInfo *Z80_MC::createZ80MCSubtargetInfo(const Triple &TT, 45 | StringRef CPU, StringRef FS) { 46 | std::string ArchFS = Z80_MC::ParseZ80Triple(TT); 47 | if (!FS.empty()) { 48 | if (!ArchFS.empty()) 49 | ArchFS = (Twine(ArchFS) + "," + FS).str(); 50 | else 51 | ArchFS = FS; 52 | } 53 | 54 | return createZ80MCSubtargetInfoImpl(TT, CPU, ArchFS); 55 | } 56 | 57 | static MCInstrInfo *createZ80MCInstrInfo() { 58 | MCInstrInfo *X = new MCInstrInfo(); 59 | InitZ80MCInstrInfo(X); 60 | return X; 61 | } 62 | 63 | static MCRegisterInfo *createZ80MCRegisterInfo(const Triple &TT) { 64 | MCRegisterInfo *X = new MCRegisterInfo(); 65 | InitZ80MCRegisterInfo(X, Z80::PC); 66 | return X; 67 | } 68 | 69 | static MCAsmInfo *createZ80MCAsmInfo(const MCRegisterInfo &MRI, 70 | const Triple &TheTriple) { 71 | return new Z80MCAsmInfo(TheTriple); 72 | } 73 | 74 | static MCInstPrinter *createZ80MCInstPrinter(const Triple &TT, 75 | unsigned SyntaxVariant, 76 | const MCAsmInfo &MAI, 77 | const MCInstrInfo &MII, 78 | const MCRegisterInfo &MRI) { 79 | switch (SyntaxVariant) { 80 | default: return nullptr; 81 | case 0: return new Z80InstPrinter(MAI, MII, MRI); 82 | case 1: return new Z80EInstPrinter(MAI, MII, MRI); 83 | } 84 | } 85 | 86 | static MCTargetStreamer *createAsmTargetStreamer(MCStreamer &S, 87 | formatted_raw_ostream &OS, 88 | MCInstPrinter */*InstPrint*/, 89 | bool /*isVerboseAsm*/) { 90 | return new Z80TargetAsmStreamer(S, OS); 91 | } 92 | 93 | // Force static initialization. 94 | extern "C" void LLVMInitializeZ80TargetMC() { 95 | for (Target *T : {&getTheZ80Target(), &getTheEZ80Target()}) { 96 | // Register the MC asm info. 97 | RegisterMCAsmInfoFn X(*T, createZ80MCAsmInfo); 98 | 99 | // Register the MC instruction info. 100 | TargetRegistry::RegisterMCInstrInfo(*T, createZ80MCInstrInfo); 101 | 102 | // Register the MC register info. 103 | TargetRegistry::RegisterMCRegInfo(*T, createZ80MCRegisterInfo); 104 | 105 | // Register the MC subtarget info. 106 | TargetRegistry::RegisterMCSubtargetInfo(*T, 107 | Z80_MC::createZ80MCSubtargetInfo); 108 | 109 | // Register the MCInstPrinter. 110 | TargetRegistry::RegisterMCInstPrinter(*T, createZ80MCInstPrinter); 111 | 112 | // Register the asm target streamer. 113 | TargetRegistry::RegisterAsmTargetStreamer(*T, createAsmTargetStreamer); 114 | } 115 | 116 | TargetRegistry::RegisterMCAsmBackend(getTheZ80Target(), createZ80AsmBackend); 117 | TargetRegistry::RegisterMCAsmBackend(getTheEZ80Target(), 118 | createEZ80AsmBackend); 119 | } 120 | -------------------------------------------------------------------------------- /lib/Target/Z80/Z80RegisterInfo.h: -------------------------------------------------------------------------------- 1 | //===-- Z80RegisterInfo.h - Z80 Register Information Impl -------*- C++ -*-===// 2 | // 3 | // The LLVM Compiler Infrastructure 4 | // 5 | // This file is distributed under the University of Illinois Open Source 6 | // License. See LICENSE.TXT for details. 7 | // 8 | //===----------------------------------------------------------------------===// 9 | // 10 | // This file contains the Z80 implementation of the TargetRegisterInfo class. 11 | // 12 | //===----------------------------------------------------------------------===// 13 | 14 | #ifndef LLVM_LIB_TARGET_Z80_Z80REGISTERINFO_H 15 | #define LLVM_LIB_TARGET_Z80_Z80REGISTERINFO_H 16 | 17 | #include "llvm/CodeGen/TargetRegisterInfo.h" 18 | 19 | #define GET_REGINFO_HEADER 20 | #include "Z80GenRegisterInfo.inc" 21 | 22 | namespace llvm { 23 | class Triple; 24 | 25 | class Z80RegisterInfo final : public Z80GenRegisterInfo { 26 | /// Is24bit - Is the target 24-bits. 27 | /// 28 | bool Is24Bit; 29 | 30 | public: 31 | Z80RegisterInfo(const Triple &TT); 32 | 33 | /// Code Generation virtual methods... 34 | /// 35 | bool trackLivenessAfterRegAlloc(const MachineFunction &MF) const override { 36 | // Z80MachineLateOptimization requires liveness. 37 | return true; 38 | } 39 | 40 | /// getPointerRegClass - Returns a TargetRegisterClass used for pointer 41 | /// values. 42 | const TargetRegisterClass * 43 | getPointerRegClass(const MachineFunction &MF, 44 | unsigned Kind = 0) const override; 45 | const TargetRegisterClass * 46 | getLargestLegalSuperClass(const TargetRegisterClass *RC, 47 | const MachineFunction &) const override; 48 | 49 | unsigned getRegPressureLimit(const TargetRegisterClass *RC, 50 | MachineFunction &MF) const override; 51 | 52 | /// getCalleeSavedRegs - Return a null-terminated list of all of the 53 | /// callee-save registers on this target. 54 | const MCPhysReg *getCalleeSavedRegs(const MachineFunction *MF) const override; 55 | const uint32_t *getCallPreservedMask(const MachineFunction &MF, 56 | CallingConv::ID CC) const override; 57 | const uint32_t *getNoPreservedMask() const override; 58 | 59 | /// getReservedRegs - Returns a bitset indexed by physical register number 60 | /// indicating if a register is a special register that has particular uses 61 | /// and should be considered unavailable at all times, e.g. SP, RA. This is 62 | /// used by register scaverger to determine what registers are free. 63 | BitVector getReservedRegs(const MachineFunction &MF) const override; 64 | 65 | bool requiresRegisterScavenging(const MachineFunction &MF) const override { 66 | return true; 67 | } 68 | 69 | bool saveScavengerRegister(MachineBasicBlock &MBB, 70 | MachineBasicBlock::iterator MI, 71 | MachineBasicBlock::iterator &UseMI, 72 | const TargetRegisterClass *RC, 73 | unsigned Reg) const override; 74 | 75 | void eliminateFrameIndex(MachineBasicBlock::iterator MI, 76 | int SPAdj, unsigned FIOperandNum, 77 | RegScavenger *RS = nullptr) const override; 78 | 79 | // Support for virtual base registers. 80 | bool requiresVirtualBaseRegisters(const MachineFunction &MF) const override; 81 | bool needsFrameBaseReg(MachineInstr *MI, int64_t Offset) const override; 82 | void materializeFrameBaseRegister(MachineBasicBlock *MBB, 83 | unsigned BaseReg, int FrameIdx, 84 | int64_t Offset) const override; 85 | void resolveFrameIndex(MachineInstr &MI, unsigned BaseReg, 86 | int64_t Offset) const override; 87 | bool isFrameOffsetLegal(const MachineInstr *MI, unsigned BaseReg, 88 | int64_t Offset) const override; 89 | 90 | // Debug information queries. 91 | unsigned getFrameRegister(const MachineFunction &MF) const override; 92 | 93 | /// \brief SrcRC and DstRC will be morphed into NewRC if this returns true. 94 | bool shouldCoalesce(MachineInstr *MI, 95 | const TargetRegisterClass *SrcRC, 96 | unsigned SubReg, 97 | const TargetRegisterClass *DstRC, 98 | unsigned DstSubReg, 99 | const TargetRegisterClass *NewRC, 100 | LiveIntervals &LIS) const override; 101 | }; 102 | } // End llvm namespace 103 | 104 | #endif 105 | -------------------------------------------------------------------------------- /test/CodeGen/X86/legalize-shl-vec.ll: -------------------------------------------------------------------------------- 1 | ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py 2 | ; RUN: llc < %s -mtriple=i686-unknown-unknown | FileCheck %s --check-prefix=CHECK --check-prefix=X32 3 | ; RUN: llc < %s -mtriple=x86_64-unknown-unknown | FileCheck %s --check-prefix=CHECK --check-prefix=X64 4 | 5 | define <2 x i256> @test_shl(<2 x i256> %In) { 6 | ; X32-LABEL: test_shl: 7 | ; X32: # BB#0: 8 | ; X32-NEXT: movl {{[0-9]+}}(%esp), %eax 9 | ; X32-NEXT: movl {{[0-9]+}}(%esp), %ecx 10 | ; X32-NEXT: shll $31, %ecx 11 | ; X32-NEXT: movl %ecx, 28(%eax) 12 | ; X32-NEXT: movl $0, 60(%eax) 13 | ; X32-NEXT: movl $0, 56(%eax) 14 | ; X32-NEXT: movl $0, 52(%eax) 15 | ; X32-NEXT: movl $0, 48(%eax) 16 | ; X32-NEXT: movl $0, 44(%eax) 17 | ; X32-NEXT: movl $0, 40(%eax) 18 | ; X32-NEXT: movl $0, 36(%eax) 19 | ; X32-NEXT: movl $0, 32(%eax) 20 | ; X32-NEXT: movl $0, 24(%eax) 21 | ; X32-NEXT: movl $0, 20(%eax) 22 | ; X32-NEXT: movl $0, 16(%eax) 23 | ; X32-NEXT: movl $0, 12(%eax) 24 | ; X32-NEXT: movl $0, 8(%eax) 25 | ; X32-NEXT: movl $0, 4(%eax) 26 | ; X32-NEXT: movl $0, (%eax) 27 | ; X32-NEXT: retl $4 28 | ; 29 | ; X64-LABEL: test_shl: 30 | ; X64: # BB#0: 31 | ; X64-NEXT: xorps %xmm0, %xmm0 32 | ; X64-NEXT: movaps %xmm0, 48(%rdi) 33 | ; X64-NEXT: movaps %xmm0, 32(%rdi) 34 | ; X64-NEXT: movaps %xmm0, 16(%rdi) 35 | ; X64-NEXT: movaps %xmm0, (%rdi) 36 | ; X64-NEXT: movq %rdi, %rax 37 | ; X64-NEXT: retq 38 | %Amt = insertelement <2 x i256> undef, i256 255, i32 0 39 | %Out = shl <2 x i256> %In, %Amt 40 | ret <2 x i256> %Out 41 | } 42 | 43 | define <2 x i256> @test_srl(<2 x i256> %In) { 44 | ; X32-LABEL: test_srl: 45 | ; X32: # BB#0: 46 | ; X32-NEXT: movl {{[0-9]+}}(%esp), %eax 47 | ; X32-NEXT: movl {{[0-9]+}}(%esp), %ecx 48 | ; X32-NEXT: shrl $31, %ecx 49 | ; X32-NEXT: movl %ecx, (%eax) 50 | ; X32-NEXT: movl $0, 60(%eax) 51 | ; X32-NEXT: movl $0, 56(%eax) 52 | ; X32-NEXT: movl $0, 52(%eax) 53 | ; X32-NEXT: movl $0, 48(%eax) 54 | ; X32-NEXT: movl $0, 44(%eax) 55 | ; X32-NEXT: movl $0, 40(%eax) 56 | ; X32-NEXT: movl $0, 36(%eax) 57 | ; X32-NEXT: movl $0, 32(%eax) 58 | ; X32-NEXT: movl $0, 28(%eax) 59 | ; X32-NEXT: movl $0, 24(%eax) 60 | ; X32-NEXT: movl $0, 20(%eax) 61 | ; X32-NEXT: movl $0, 16(%eax) 62 | ; X32-NEXT: movl $0, 12(%eax) 63 | ; X32-NEXT: movl $0, 8(%eax) 64 | ; X32-NEXT: movl $0, 4(%eax) 65 | ; X32-NEXT: retl $4 66 | ; 67 | ; X64-LABEL: test_srl: 68 | ; X64: # BB#0: 69 | ; X64-NEXT: xorps %xmm0, %xmm0 70 | ; X64-NEXT: movaps %xmm0, 48(%rdi) 71 | ; X64-NEXT: movaps %xmm0, 32(%rdi) 72 | ; X64-NEXT: movaps %xmm0, 16(%rdi) 73 | ; X64-NEXT: movaps %xmm0, (%rdi) 74 | ; X64-NEXT: movq %rdi, %rax 75 | ; X64-NEXT: retq 76 | %Amt = insertelement <2 x i256> undef, i256 255, i32 0 77 | %Out = lshr <2 x i256> %In, %Amt 78 | ret <2 x i256> %Out 79 | } 80 | 81 | define <2 x i256> @test_sra(<2 x i256> %In) { 82 | ; X32-LABEL: test_sra: 83 | ; X32: # BB#0: 84 | ; X32-NEXT: movl {{[0-9]+}}(%esp), %eax 85 | ; X32-NEXT: movl {{[0-9]+}}(%esp), %ecx 86 | ; X32-NEXT: movl %ecx, 60(%eax) 87 | ; X32-NEXT: movl {{[0-9]+}}(%esp), %ecx 88 | ; X32-NEXT: movl %ecx, 56(%eax) 89 | ; X32-NEXT: movl {{[0-9]+}}(%esp), %ecx 90 | ; X32-NEXT: movl %ecx, 52(%eax) 91 | ; X32-NEXT: movl {{[0-9]+}}(%esp), %ecx 92 | ; X32-NEXT: movl %ecx, 48(%eax) 93 | ; X32-NEXT: movl {{[0-9]+}}(%esp), %ecx 94 | ; X32-NEXT: movl %ecx, 44(%eax) 95 | ; X32-NEXT: movl {{[0-9]+}}(%esp), %ecx 96 | ; X32-NEXT: movl %ecx, 40(%eax) 97 | ; X32-NEXT: movl {{[0-9]+}}(%esp), %ecx 98 | ; X32-NEXT: movl %ecx, 36(%eax) 99 | ; X32-NEXT: movl {{[0-9]+}}(%esp), %ecx 100 | ; X32-NEXT: movl %ecx, 32(%eax) 101 | ; X32-NEXT: movl {{[0-9]+}}(%esp), %ecx 102 | ; X32-NEXT: sarl $31, %ecx 103 | ; X32-NEXT: movl %ecx, 28(%eax) 104 | ; X32-NEXT: movl %ecx, 24(%eax) 105 | ; X32-NEXT: movl %ecx, 20(%eax) 106 | ; X32-NEXT: movl %ecx, 16(%eax) 107 | ; X32-NEXT: movl %ecx, 12(%eax) 108 | ; X32-NEXT: movl %ecx, 8(%eax) 109 | ; X32-NEXT: movl %ecx, 4(%eax) 110 | ; X32-NEXT: movl %ecx, (%eax) 111 | ; X32-NEXT: retl $4 112 | ; 113 | ; X64-LABEL: test_sra: 114 | ; X64: # BB#0: 115 | ; X64-NEXT: movq {{[0-9]+}}(%rsp), %rax 116 | ; X64-NEXT: movq {{[0-9]+}}(%rsp), %rcx 117 | ; X64-NEXT: movq {{[0-9]+}}(%rsp), %rdx 118 | ; X64-NEXT: sarq $63, %r8 119 | ; X64-NEXT: movq %rdx, 56(%rdi) 120 | ; X64-NEXT: movq %rcx, 48(%rdi) 121 | ; X64-NEXT: movq %rax, 40(%rdi) 122 | ; X64-NEXT: movq %r9, 32(%rdi) 123 | ; X64-NEXT: movq %r8, 24(%rdi) 124 | ; X64-NEXT: movq %r8, 16(%rdi) 125 | ; X64-NEXT: movq %r8, 8(%rdi) 126 | ; X64-NEXT: movq %r8, (%rdi) 127 | ; X64-NEXT: movq %rdi, %rax 128 | ; X64-NEXT: retq 129 | %Amt = insertelement <2 x i256> undef, i256 255, i32 0 130 | %Out = ashr <2 x i256> %In, %Amt 131 | ret <2 x i256> %Out 132 | } 133 | -------------------------------------------------------------------------------- /lib/Target/Z80/Z80TargetMachine.cpp: -------------------------------------------------------------------------------- 1 | //===-- Z80TargetMachine.cpp - Define TargetMachine for the Z80 -----------===// 2 | // 3 | // The LLVM Compiler Infrastructure 4 | // 5 | // This file is distributed under the University of Illinois Open Source 6 | // License. See LICENSE.TXT for details. 7 | // 8 | //===----------------------------------------------------------------------===// 9 | // 10 | // This file defines the Z80 specific subclass of TargetMachine. 11 | // 12 | //===----------------------------------------------------------------------===// 13 | 14 | #include "Z80TargetMachine.h" 15 | #include "Z80.h" 16 | #include "llvm/CodeGen/Passes.h" 17 | #include "llvm/CodeGen/TargetPassConfig.h" 18 | #include "llvm/CodeGen/TargetLoweringObjectFileImpl.h" 19 | #include "llvm/Support/TargetRegistry.h" 20 | #include "llvm/Transforms/Scalar.h" 21 | using namespace llvm; 22 | 23 | extern "C" void LLVMInitializeZ80Target() { 24 | // Register the target. 25 | RegisterTargetMachine X(getTheZ80Target()); 26 | RegisterTargetMachine Y(getTheEZ80Target()); 27 | } 28 | 29 | static std::string computeDataLayout(const Triple &TT) { 30 | bool IsEZ80 = TT.getArch() == Triple::ez80; 31 | bool Is16Bit = TT.isArch16Bit() || TT.getEnvironment() == Triple::CODE16; 32 | // Z80 is little endian and mangling is closest to MachO. 33 | std::string Ret = "e-m:o"; 34 | // Memory Address Width 35 | Ret += Is16Bit ? "-p:16:8" : "-p:24:8"; 36 | // Port Address Width 37 | Ret += IsEZ80 ? "-p1:16:8" : "-p1:8:8"; 38 | // Other Address Width 39 | if (IsEZ80) 40 | Ret += Is16Bit ? "-p2:24:8" : "-p2:16:8"; 41 | Ret += "-i16:8-i24:8-i32:8-i48:8-i64:8-i96:8-f32:8-f64:8-a:8-n8:16"; 42 | if (!Is16Bit) 43 | Ret += ":24"; 44 | Ret += "-S8"; 45 | return Ret; 46 | } 47 | 48 | static Reloc::Model getEffectiveRelocModel(Optional RM) { 49 | if (RM) 50 | return *RM; 51 | return Reloc::Static; 52 | } 53 | 54 | static CodeModel::Model getEffectiveCodeModel(Optional CM) { 55 | if (CM) 56 | return *CM; 57 | return CodeModel::Small; 58 | } 59 | 60 | /// Z80TargetMachine ctor - Create a Z80 target. 61 | /// 62 | Z80TargetMachine::Z80TargetMachine(const Target &T, const Triple &TT, 63 | StringRef CPU, StringRef FS, 64 | const TargetOptions &Options, 65 | Optional RM, 66 | Optional CM, 67 | CodeGenOpt::Level OL, bool JIT) 68 | : LLVMTargetMachine(T, computeDataLayout(TT), TT, CPU, FS, Options, 69 | getEffectiveRelocModel(RM), getEffectiveCodeModel(CM), 70 | OL), 71 | TLOF(make_unique()) { 72 | initAsmInfo(); 73 | } 74 | 75 | Z80TargetMachine::~Z80TargetMachine() {} 76 | 77 | const Z80Subtarget * 78 | Z80TargetMachine::getSubtargetImpl(const Function &F) const { 79 | Attribute CPUAttr = F.getFnAttribute("target-cpu"); 80 | Attribute FSAttr = F.getFnAttribute("target-features"); 81 | 82 | StringRef CPU = !CPUAttr.hasAttribute(Attribute::None) 83 | ? CPUAttr.getValueAsString() 84 | : (StringRef)TargetCPU; 85 | StringRef FS = !FSAttr.hasAttribute(Attribute::None) 86 | ? FSAttr.getValueAsString() 87 | : (StringRef)TargetFS; 88 | 89 | SmallString<512> Key; 90 | Key.reserve(CPU.size() + FS.size()); 91 | Key += CPU; 92 | Key += FS; 93 | 94 | auto &I = SubtargetMap[Key]; 95 | if (!I) { 96 | // This needs to be done before we create a new subtarget since any 97 | // creation will depend on the TM and the code generation flags on the 98 | // function that reside in TargetOptions. 99 | resetTargetOptions(F); 100 | I = llvm::make_unique(TargetTriple, CPU, FS, *this); 101 | } 102 | return I.get(); 103 | } 104 | 105 | //===----------------------------------------------------------------------===// 106 | // Pass Pipeline Configuration 107 | //===----------------------------------------------------------------------===// 108 | 109 | namespace { 110 | /// Z80 Code Generator Pass Configuration Options. 111 | class Z80PassConfig : public TargetPassConfig { 112 | public: 113 | Z80PassConfig(Z80TargetMachine &TM, PassManagerBase &PM) 114 | : TargetPassConfig(TM, PM) {} 115 | 116 | Z80TargetMachine &getZ80TargetMachine() const { 117 | return getTM(); 118 | } 119 | 120 | void addCodeGenPrepare() override; 121 | bool addInstSelector() override; 122 | //void addPreRegAlloc() override; 123 | //bool addPreRewrite() override; 124 | //void addPreSched2() override; 125 | }; 126 | } // namespace 127 | 128 | TargetPassConfig *Z80TargetMachine::createPassConfig(PassManagerBase &PM) { 129 | return new Z80PassConfig(*this, PM); 130 | } 131 | 132 | void Z80PassConfig::addCodeGenPrepare() { 133 | addPass(createLowerSwitchPass()); 134 | TargetPassConfig::addCodeGenPrepare(); 135 | } 136 | 137 | bool Z80PassConfig::addInstSelector() { 138 | // Install an instruction selector. 139 | addPass(createZ80ISelDag(getZ80TargetMachine(), getOptLevel())); 140 | return false; 141 | } 142 | 143 | /*void Z80PassConfig::addPreRegAlloc() { 144 | TargetPassConfig::addPreRegAlloc(); 145 | if (getOptLevel() != CodeGenOpt::None) 146 | ;//addPass(createZ80CallFrameOptimization()); 147 | } 148 | 149 | bool Z80PassConfig::addPreRewrite() { 150 | //addPass(createZ80ExpandPseudoPass()); 151 | return TargetPassConfig::addPreRewrite(); 152 | } 153 | 154 | void Z80PassConfig::addPreSched2() { 155 | // Z80MachineLateOptimization pass must be run after ExpandPostRAPseudos 156 | if (getOptLevel() != CodeGenOpt::None) 157 | addPass(createZ80MachineLateOptimization()); 158 | TargetPassConfig::addPreSched2(); 159 | } 160 | */ 161 | -------------------------------------------------------------------------------- /tools/clang/include/clang/module.modulemap: -------------------------------------------------------------------------------- 1 | module Clang_Analysis { 2 | requires cplusplus 3 | umbrella "Analysis" 4 | 5 | textual header "Analysis/Analyses/ThreadSafetyOps.def" 6 | 7 | module * { export * } 8 | } 9 | 10 | module Clang_AST { 11 | requires cplusplus 12 | umbrella "AST" 13 | 14 | textual header "AST/BuiltinTypes.def" 15 | textual header "AST/OperationKinds.def" 16 | textual header "AST/TypeLocNodes.def" 17 | textual header "AST/TypeNodes.def" 18 | 19 | module * { export * } 20 | } 21 | 22 | module Clang_ASTMatchers { requires cplusplus umbrella "ASTMatchers" module * { export * } } 23 | 24 | module Clang_Basic { 25 | requires cplusplus 26 | umbrella "Basic" 27 | 28 | textual header "Basic/BuiltinsAArch64.def" 29 | textual header "Basic/BuiltinsAMDGPU.def" 30 | textual header "Basic/BuiltinsARM.def" 31 | textual header "Basic/Builtins.def" 32 | textual header "Basic/BuiltinsHexagon.def" 33 | textual header "Basic/BuiltinsLe64.def" 34 | textual header "Basic/BuiltinsMips.def" 35 | textual header "Basic/BuiltinsNEON.def" 36 | textual header "Basic/BuiltinsNios2.def" 37 | textual header "Basic/BuiltinsNVPTX.def" 38 | textual header "Basic/BuiltinsPPC.def" 39 | textual header "Basic/BuiltinsSystemZ.def" 40 | textual header "Basic/BuiltinsWebAssembly.def" 41 | textual header "Basic/BuiltinsX86.def" 42 | textual header "Basic/BuiltinsX86_64.def" 43 | textual header "Basic/BuiltinsXCore.def" 44 | textual header "Basic/DiagnosticOptions.def" 45 | textual header "Basic/LangOptions.def" 46 | textual header "Basic/OpenCLExtensions.def" 47 | textual header "Basic/OpenCLImageTypes.def" 48 | textual header "Basic/OpenMPKinds.def" 49 | textual header "Basic/OperatorKinds.def" 50 | textual header "Basic/Sanitizers.def" 51 | textual header "Basic/TokenKinds.def" 52 | textual header "Basic/X86Target.def" 53 | 54 | module * { export * } 55 | } 56 | 57 | module Clang_CodeGen { requires cplusplus umbrella "CodeGen" module * { export * } } 58 | module Clang_Config { requires cplusplus umbrella "Config" module * { export * } } 59 | 60 | // Files for diagnostic groups are spread all over the include/clang/ tree, but 61 | // logically form a single module. 62 | module Clang_Diagnostics { 63 | requires cplusplus 64 | 65 | module All { header "Basic/AllDiagnostics.h" export * } 66 | module Analysis { header "Analysis/AnalysisDiagnostic.h" export * } 67 | module AST { header "AST/ASTDiagnostic.h" export * } 68 | module Comment { header "AST/CommentDiagnostic.h" export * } 69 | module Driver { header "Driver/DriverDiagnostic.h" export * } 70 | module Frontend { header "Frontend/FrontendDiagnostic.h" export * } 71 | module Lex { header "Lex/LexDiagnostic.h" export * } 72 | module Parse { header "Parse/ParseDiagnostic.h" export * } 73 | module Sema { header "Sema/SemaDiagnostic.h" export * } 74 | module Serialization { header "Serialization/SerializationDiagnostic.h" export * } 75 | module Refactoring { header "Tooling/Refactoring/RefactoringDiagnostic.h" export * } 76 | } 77 | 78 | module Clang_Driver { 79 | requires cplusplus 80 | umbrella "Driver" 81 | 82 | textual header "Driver/Types.def" 83 | 84 | module * { export * } 85 | } 86 | 87 | module Clang_Edit { requires cplusplus umbrella "Edit" module * { export * } } 88 | module Clang_Format { requires cplusplus umbrella "Format" module * { export * } } 89 | 90 | module Clang_Frontend { 91 | requires cplusplus 92 | umbrella "Frontend" 93 | 94 | textual header "Frontend/LangStandards.def" 95 | 96 | module * { export * } 97 | 98 | // FIXME: This violates layers. 99 | exclude header "Frontend/PCHContainerOperations.h" 100 | } 101 | 102 | // Used in clangBasic 103 | module Clang_Frontend_CodeGenOptions { 104 | requires cplusplus 105 | header "Frontend/CodeGenOptions.h" 106 | textual header "Frontend/CodeGenOptions.def" 107 | export * 108 | } 109 | 110 | module Clang_FrontendTool { requires cplusplus umbrella "FrontendTool" module * { export * } } 111 | module Clang_Index { requires cplusplus umbrella "Index" module * { export * } } 112 | module Clang_Lex { requires cplusplus umbrella "Lex" module * { export * } } 113 | module Clang_Parse { requires cplusplus umbrella "Parse" module * { export * } } 114 | module Clang_Rewrite { requires cplusplus umbrella "Rewrite/Core" module * { export * } } 115 | module Clang_RewriteFrontend { requires cplusplus umbrella "Rewrite/Frontend" module * { export * } } 116 | module Clang_Sema { requires cplusplus umbrella "Sema" module * { export * } } 117 | module Clang_Serialization { requires cplusplus umbrella "Serialization" module * { export * } } 118 | 119 | module Clang_StaticAnalyzer_Core { 120 | requires cplusplus 121 | umbrella "StaticAnalyzer/Core" 122 | 123 | textual header "StaticAnalyzer/Core/Analyses.def" 124 | textual header "StaticAnalyzer/Core/PathSensitive/SVals.def" 125 | textual header "StaticAnalyzer/Core/PathSensitive/Symbols.def" 126 | textual header "StaticAnalyzer/Core/PathSensitive/Regions.def" 127 | 128 | module * { export * } 129 | } 130 | 131 | module Clang_StaticAnalyzer_Checkers { 132 | requires cplusplus 133 | umbrella "StaticAnalyzer/Checkers" 134 | module * { export * } 135 | } 136 | 137 | module Clang_StaticAnalyzer_Frontend { 138 | requires cplusplus 139 | umbrella "StaticAnalyzer/Frontend" 140 | module * { export * } 141 | } 142 | 143 | module Clang_Tooling { 144 | requires cplusplus umbrella "Tooling" module * { export * } 145 | // FIXME: Exclude these headers to avoid pulling all of the AST matchers 146 | // library into clang-format. Due to inline key functions in the headers, 147 | // importing the AST matchers library gives a link dependency on the AST 148 | // matchers (and thus the AST), which clang-format should not have. 149 | exclude header "Tooling/RefactoringCallbacks.h" 150 | } 151 | 152 | module Clang_ToolingCore { 153 | requires cplusplus 154 | umbrella "Tooling/Core" module * { export * } 155 | } 156 | -------------------------------------------------------------------------------- /lib/Target/Z80/Z80ISelDAGToDAG.cpp: -------------------------------------------------------------------------------- 1 | //===- Z80ISelDAGToDAG.cpp - A DAG pattern matching inst selector for Z80 -===// 2 | // 3 | // The LLVM Compiler Infrastructure 4 | // 5 | // This file is distributed under the University of Illinois Open Source 6 | // License. See LICENSE.TXT for details. 7 | // 8 | //===----------------------------------------------------------------------===// 9 | // 10 | // This file defines a DAG pattern matching instruction selector for Z80, 11 | // converting from a legalized dag to a Z80 dag. 12 | // 13 | //===----------------------------------------------------------------------===// 14 | 15 | #include "Z80.h" 16 | #include "Z80Subtarget.h" 17 | #include "Z80TargetMachine.h" 18 | #include "llvm/CodeGen/SelectionDAGISel.h" 19 | using namespace llvm; 20 | 21 | #define DEBUG_TYPE "z80-isel" 22 | 23 | namespace { 24 | //===--------------------------------------------------------------------===// 25 | /// ISel - Z80-specific code to select Z80 machine instructions for 26 | /// SelectionDAG operations. 27 | /// 28 | class Z80DAGToDAGISel final : public SelectionDAGISel { 29 | /// Keep a pointer to the Z80Subtarget around so that we can 30 | /// make the right decision when generating code for different targets. 31 | const Z80Subtarget *Subtarget; 32 | 33 | /// If true, selector should try to optimize for code size instead of 34 | /// performance. 35 | bool OptForSize; 36 | 37 | public: 38 | explicit Z80DAGToDAGISel(Z80TargetMachine &TM, CodeGenOpt::Level OptLevel) 39 | : SelectionDAGISel(TM, OptLevel), OptForSize(false) {} 40 | 41 | StringRef getPassName() const override { 42 | return "Z80 DAG->DAG Instruction Selection"; 43 | } 44 | 45 | bool runOnMachineFunction(MachineFunction &MF) override { 46 | // Reset the subtarget each time through. 47 | Subtarget = &MF.getSubtarget(); 48 | return SelectionDAGISel::runOnMachineFunction(MF); 49 | } 50 | 51 | // Include the pieces autogenerated from the target description. 52 | #include "Z80GenDAGISel.inc" 53 | 54 | private: 55 | void Select(SDNode *N) override; 56 | 57 | bool SelectMem(SDValue N, SDValue &Mem); 58 | bool SelectOff(SDValue N, SDValue &Reg, SDValue &Off); 59 | bool SelectFI(SDValue N, SDValue &Reg, SDValue &Off); 60 | 61 | /// Implement addressing mode selection for inline asm expressions. 62 | bool SelectInlineAsmMemoryOperand(const SDValue &Op, unsigned ConstraintID, 63 | std::vector &OutOps) override; 64 | }; 65 | } 66 | 67 | void Z80DAGToDAGISel::Select(SDNode *Node) { 68 | SDLoc DL(Node); 69 | 70 | // Dump information about the Node being selected 71 | DEBUG(dbgs() << "Selecting: "; Node->dump(CurDAG); dbgs() << '\n'); 72 | 73 | // If we have a custom node, we already have selected! 74 | if (Node->isMachineOpcode()) { 75 | DEBUG(dbgs() << "== "; Node->dump(CurDAG); dbgs() << '\n'); 76 | Node->setNodeId(-1); 77 | return; 78 | } 79 | 80 | // Select the default instruction 81 | SelectCode(Node); 82 | } 83 | 84 | bool Z80DAGToDAGISel::SelectMem(SDValue N, SDValue &Mem) { 85 | switch (N.getOpcode()) { 86 | default: 87 | DEBUG(dbgs() << "SelectMem: " << N->getOperationName() << '\n'); 88 | return false; 89 | case ISD::Constant: { 90 | uint64_t Val = cast(N)->getSExtValue(); 91 | Mem = CurDAG->getTargetConstant(Val, SDLoc(N), MVT::i24); 92 | return true; 93 | } 94 | case Z80ISD::Wrapper: { 95 | Mem = N->getOperand(0); 96 | return true; 97 | } 98 | } 99 | } 100 | bool Z80DAGToDAGISel::SelectOff(SDValue N, SDValue &Reg, SDValue &Off) { 101 | switch (N.getOpcode()) { 102 | default: return false; 103 | case ISD::ADD: 104 | for (int I = 0; I != 2; ++I) { 105 | if (ConstantSDNode *C = dyn_cast(N.getOperand(I))) { 106 | int64_t Val = C->getSExtValue(); 107 | if (!isInt<8>(Val)) 108 | continue; 109 | Reg = N.getOperand(1 - I); 110 | FrameIndexSDNode *Idx = dyn_cast(Reg); 111 | if (Val >= -1 && Val <= 1 && !Idx && Reg.hasOneUse()) 112 | continue; 113 | if (Idx) 114 | Reg = CurDAG->getTargetFrameIndex( 115 | Idx->getIndex(), TLI->getPointerTy(CurDAG->getDataLayout())); 116 | Off = CurDAG->getTargetConstant(Val, SDLoc(N), MVT::i8); 117 | DEBUG(dbgs() << "Selected ADD:\n"; 118 | N.dumpr(); 119 | dbgs() << "becomes\n"; 120 | Reg.dumpr(); 121 | Off.dumpr()); 122 | return true; 123 | } 124 | } 125 | return false; 126 | case ISD::FrameIndex: 127 | Reg = CurDAG->getTargetFrameIndex( 128 | cast(N)->getIndex(), 129 | TLI->getPointerTy(CurDAG->getDataLayout())); 130 | Off = CurDAG->getTargetConstant(0, SDLoc(N), MVT::i8); 131 | return true; 132 | } 133 | } 134 | bool Z80DAGToDAGISel::SelectFI(SDValue N, SDValue &Reg, SDValue &Off) { 135 | if (!SelectOff(N, Reg, Off)) 136 | return false; 137 | return isa(Reg); 138 | } 139 | 140 | bool Z80DAGToDAGISel:: 141 | SelectInlineAsmMemoryOperand(const SDValue &Op, unsigned ConstraintID, 142 | std::vector &OutOps) { 143 | SDValue Op0, Op1; 144 | switch (ConstraintID) { 145 | default: 146 | llvm_unreachable("Unexpected asm memory constraint"); 147 | case InlineAsm::Constraint_m: 148 | if (!SelectMem(Op, Op0)) 149 | return true; 150 | OutOps.push_back(Op0); 151 | return false; 152 | case InlineAsm::Constraint_o: 153 | if (!SelectOff(Op, Op0, Op1)) 154 | return true; 155 | OutOps.push_back(Op0); 156 | OutOps.push_back(Op1); 157 | return false; 158 | } 159 | } 160 | 161 | /// This pass converts a legalized DAG into Z80-specific DAG, 162 | /// ready for instruction scheduling. 163 | FunctionPass *llvm::createZ80ISelDag(Z80TargetMachine &TM, 164 | CodeGenOpt::Level OptLevel) { 165 | return new Z80DAGToDAGISel(TM, OptLevel); 166 | } 167 | -------------------------------------------------------------------------------- /include/llvm/Object/OMF.h: -------------------------------------------------------------------------------- 1 | //===- OMF.h - OMF object file implementation -------------------*- C++ -*-===// 2 | // 3 | // The LLVM Compiler Infrastructure 4 | // 5 | // This file is distributed under the University of Illinois Open Source 6 | // License. See LICENSE.TXT for details. 7 | // 8 | //===----------------------------------------------------------------------===// 9 | // 10 | // This file declares the OMFObjectFile class. 11 | // 12 | //===----------------------------------------------------------------------===// 13 | 14 | #ifndef LLVM_OBJECT_OMF_H 15 | #define LLVM_OBJECT_OMF_H 16 | 17 | #include "llvm/ADT/MapVector.h" 18 | #include "llvm/Object/ObjectFile.h" 19 | #include "llvm/Support/Endian.h" 20 | 21 | namespace llvm { 22 | namespace object { 23 | 24 | // OMF Record IDs 25 | constexpr StringLiteral 26 | OMF_AssignValToVar("\xE2\xD7"), 27 | OMF_DefineContext("\xFB"); 28 | 29 | // OMF Record headers 30 | enum { 31 | OMF_COMMA = 0x90, ///< , 32 | OMF_FALSE = 0xA0, ///< @F 33 | OMF_TRUE = 0xA1, ///< @T 34 | OMF_ABS = 0xA2, ///< @ABS 35 | OMF_NEG = 0xA3, ///< @NEG 36 | OMF_NOT = 0xA4, ///< @NOT 37 | OMF_ADD = 0xA5, ///< + 38 | OMF_SUB = 0xA6, ///< - 39 | OMF_DIV = 0xA7, ///< / 40 | OMF_MUL = 0xA8, ///< * 41 | OMF_MAX = 0xA9, ///< @MAX 42 | OMF_MIN = 0xAA, ///< @MIN 43 | OMF_MOD = 0xAB, ///< @MOD 44 | OMF_LTHAN = 0xAC, ///< < 45 | OMF_GTHAN = 0xAD, ///< > 46 | OMF_EQUAL = 0xAE, ///< = 47 | OMF_NEQUAL = 0xAF, ///< != or <> 48 | OMF_AND = 0xB0, ///< @AND 49 | OMF_OR = 0xB1, ///< @OR 50 | OMF_XOR = 0xB2, ///< @XOR 51 | OMF_EXT = 0xB3, ///< @EXT 52 | OMF_INS = 0xB4, ///< @INS 53 | OMF_ERR = 0xB5, ///< @ERR 54 | OMF_IF = 0xB6, ///< @IF 55 | OMF_ELSE = 0xB7, ///< @ELSE 56 | OMF_END = 0xB8, ///< @END 57 | OMF_ESC = 0xB9, ///< @ESCAPE 58 | OMF_LBRACK = 0xBA, ///< [ 59 | OMF_RBRACK = 0xBB, ///< ] 60 | OMF_LBRACE = 0xBC, ///< { 61 | OMF_RBRACE = 0xBD, ///< } 62 | OMF_LPAREN = 0xBE, ///< ( 63 | OMF_RPAREN = 0xBF, ///< ) 64 | OMF_NULL = 0xC0, 65 | OMF_A = OMF_NULL|'A', ///< Type B Section Physical Address 66 | OMF_B = OMF_NULL|'B', ///< Type B Section Size 67 | OMF_F = OMF_NULL|'F', ///< Section AMU Size 68 | OMF_G = OMF_NULL|'G', ///< Execution starting address. 69 | OMF_I = OMF_NULL|'I', ///< Address of public symbol n. 70 | OMF_L = OMF_NULL|'L', ///< The logical address of a section n. 71 | OMF_M = OMF_NULL|'M', ///< The most significant half of a two part logical 72 | ///< address of a section n. 73 | OMF_N = OMF_NULL|'N', ///< Address of local symbol n. 74 | OMF_P = OMF_NULL|'P', ///< The program counter for section n. 75 | OMF_R = OMF_NULL|'R', 76 | OMF_S = OMF_NULL|'S', ///< The size, in MAUs, ,of a section n. 77 | OMF_W = OMF_NULL|'W', ///< The file offset, in bytes, of the nth part of the 78 | ///< object file. 79 | OMF_X = OMF_NULL|'X', ///< Address of external symbol n. 80 | OMF_Z = OMF_NULL|'Z', 81 | OMF_EL1 = 0xDE, ///< Extension Length 82 | OMF_EL2 = 0xDF, ///< Extension Length 83 | OMF_FIRST_RECORD = 0xE0, 84 | OMF_RECORD_MB = 0xE0, ///< Module Beginning 85 | OMF_RECORD_ME = 0xE1, ///< Module End 86 | OMF_RECORD_AS = 0xE2, ///< Assign 87 | OMF_RECORD_IR = 0xE3, ///< Initialize Relocation Base 88 | OMF_RECORD_LR = 0xE4, ///< Load With Relocation 89 | OMF_RECORD_SB = 0xE5, ///< Current Section 90 | OMF_RECORD_ST = 0xE6, ///< Section Type 91 | OMF_RECORD_SA = 0xE7, ///< Section Alignment 92 | OMF_RECORD_NI = 0xE8, ///< Public (External) Symbol 93 | OMF_RECORD_NX = 0xE9, ///< External Reference Name 94 | OMF_RECORD_AD = 0xEC, ///< Address Descriptor 95 | OMF_RECORD_LD = 0xED, ///< Load Constant MAUs 96 | OMF_RECORD_C1 = 0xEE, ///< Checksum Record 97 | OMF_RECORD_C2 = 0xEF, ///< Checksum Record 98 | OMF_RECORD_NN = 0xF0, ///< Variable Attributes 99 | OMF_RECORD_AT = 0xF1, ///< Variable Attributes 100 | OMF_RECORD_TY = 0xF2, ///< Define Type Characteristics 101 | OMF_RECORD_WX = 0xF4, ///< Weak External Reference 102 | OMF_RECORD_RE = 0xF7, ///< Repeat Data 103 | OMF_RECORD_BB = 0xF8, ///< Declare Block Beginning 104 | OMF_RECORD_BE = 0xF9, ///< Declare Block End 105 | OMF_RECORD_LT = 0xFA, ///< Load With Translation 106 | OMF_RECORD_NC = 0xFB, ///< Define Context 107 | }; 108 | 109 | // OMF Parts 110 | enum { 111 | OMF_ADExtensionPart, 112 | OMF_EnvironmentPart, 113 | OMF_SectionPart, 114 | OMF_ExternalPart, 115 | OMF_DebugInfoPart, 116 | OMF_DataPart, 117 | OMF_TrailerPart, 118 | OMF_ModuleEnd, 119 | OMF_NumParts 120 | }; 121 | 122 | // OMF Object Format Types 123 | enum { 124 | OMF_Absolute = 1, 125 | OMF_Relocatable, 126 | OMF_Loadable, 127 | OMF_Library 128 | }; 129 | 130 | // OMF Memory Models 131 | enum { 132 | OMF_Tiny, ///< Code and data are in the same single 64K segment/page. 133 | OMF_Small, ///< Code and data each have a single 64K segment/page. 134 | OMF_Medium, ///< Data has a single 64K segment/page, while code has multiple 135 | /// 64K segments/pages. 136 | OMF_Compact, ///< Data has multiple 64K segments/pages, while code has a 137 | /// single 64K segment/page. 138 | OMF_Large, ///< Both data and code have multiple 64K segments/pages. 139 | OMF_Big, ///< Code has multiple 64K segments/pages, while there is a 140 | /// common "near" data area with far data areas available; 141 | /// normally and stack are together. 142 | OMF_Huge ///< All large arrays and structures are in their own section so 143 | /// that addressing involves computations (you can have arrays 144 | /// and structures bigger than 64K). 145 | }; 146 | 147 | typedef StringRef OMFContext; 148 | 149 | struct OMFSection { 150 | StringRef Type, Name; 151 | uint64_t Parent = 0, Brother = 0, Context = 0; 152 | uint64_t Alignment = 0, PageSize = 0, Size = 0; 153 | std::string Data; 154 | }; 155 | 156 | struct OMFSymbol { 157 | uint32_t Flags = BasicSymbolRef::SF_None; 158 | StringRef Name; 159 | uint64_t Section = 0, Address = 0; 160 | }; 161 | 162 | } // end namespace object 163 | } // end namespace llvm 164 | 165 | #endif // LLVM_OBJECT_OMF_H 166 | -------------------------------------------------------------------------------- /lib/Target/Z80/Z80ExpandPseudo.cpp: -------------------------------------------------------------------------------- 1 | //===------- Z80ExpandPseudo.cpp - Expand pseudo instructions -------------===// 2 | // 3 | // The LLVM Compiler Infrastructure 4 | // 5 | // This file is distributed under the University of Illinois Open Source 6 | // License. See LICENSE.TXT for details. 7 | // 8 | //===----------------------------------------------------------------------===// 9 | // 10 | // This file contains a pass that expands pseudo instructions into target 11 | // instructions to allow proper scheduling, if-conversion, other late 12 | // optimizations, or simply the encoding of the instructions. 13 | // 14 | //===----------------------------------------------------------------------===// 15 | 16 | #include "Z80.h" 17 | #include "Z80InstrInfo.h" 18 | #include "Z80Subtarget.h" 19 | #include "../../CodeGen/LiveDebugVariables.h" 20 | #include "../../CodeGen/SpillPlacement.h" 21 | #include "llvm/CodeGen/CalcSpillWeights.h" 22 | #include "llvm/CodeGen/EdgeBundles.h" 23 | #include "llvm/CodeGen/LiveIntervalAnalysis.h" 24 | #include "llvm/CodeGen/LiveRangeEdit.h" 25 | #include "llvm/CodeGen/LiveRegMatrix.h" 26 | #include "llvm/CodeGen/LiveStackAnalysis.h" 27 | #include "llvm/CodeGen/MachineBlockFrequencyInfo.h" 28 | #include "llvm/CodeGen/MachineDominators.h" 29 | #include "llvm/CodeGen/MachineFunctionPass.h" 30 | #include "llvm/CodeGen/MachineInstr.h" 31 | #include "llvm/CodeGen/MachineInstrBuilder.h" 32 | #include "llvm/CodeGen/MachineLoopInfo.h" 33 | #include "llvm/CodeGen/MachineRegisterInfo.h" 34 | #include "llvm/CodeGen/RegAllocRegistry.h" 35 | #include "llvm/CodeGen/VirtRegMap.h" 36 | using namespace llvm; 37 | 38 | #define DEBUG_TYPE "z80-pseudo" 39 | 40 | namespace { 41 | class Z80ExpandPseudo : public MachineFunctionPass { 42 | public: 43 | Z80ExpandPseudo() : MachineFunctionPass(ID) {} 44 | 45 | bool runOnMachineFunction(MachineFunction &MF) override; 46 | 47 | MachineFunctionProperties getRequiredProperties() const override { 48 | return MachineFunctionProperties() 49 | .set(MachineFunctionProperties::Property::TracksLiveness); 50 | } 51 | 52 | void getAnalysisUsage(AnalysisUsage &AU) const override { 53 | AU.setPreservesCFG(); 54 | AU.addRequired(); 55 | AU.addPreserved(); 56 | //AU.addRequired(); 57 | //AU.addPreserved(); 58 | AU.addRequired(); 59 | AU.addPreserved(); 60 | AU.addRequired(); 61 | AU.addPreserved(); 62 | //AU.addRequired(); 63 | //AU.addPreserved(); 64 | AU.addRequired(); 65 | AU.addPreserved(); 66 | AU.addRequired(); 67 | AU.addPreserved(); 68 | AU.addRequired(); 69 | AU.addPreserved(); 70 | AU.addRequired(); 71 | AU.addPreserved(); 72 | AU.addRequired(); 73 | AU.addPreserved(); 74 | AU.addRequired(); 75 | AU.addRequired(); 76 | MachineFunctionPass::getAnalysisUsage(AU); 77 | } 78 | 79 | StringRef getPassName() const override { 80 | return "Z80 Expand Pseudo Instructions"; 81 | } 82 | 83 | private: 84 | void ExpandCmp(MachineInstr &MI, MachineBasicBlock &MBB); 85 | void ExpandCmp0(MachineInstr &MI, MachineBasicBlock &MBB); 86 | bool ExpandMI(MachineBasicBlock::iterator &MI, MachineBasicBlock &MBB); 87 | bool ExpandMBB(MachineBasicBlock &MBB); 88 | 89 | const TargetInstrInfo *TII; 90 | static char ID; 91 | }; 92 | 93 | char Z80ExpandPseudo::ID = 0; 94 | } // end anonymous namespace 95 | 96 | FunctionPass *llvm::createZ80ExpandPseudoPass() { 97 | return new Z80ExpandPseudo(); 98 | } 99 | 100 | void Z80ExpandPseudo::ExpandCmp(MachineInstr &MI, MachineBasicBlock &MBB) { 101 | bool Is24Bit = MI.getOpcode() == Z80::CP24ao; 102 | assert((Is24Bit || MI.getOpcode() == Z80::CP16ao) && "Unexpected opcode"); 103 | DebugLoc DL = MI.getDebugLoc(); 104 | dbgs() << "Z80ExpandPseudo::ExpandCmp"; 105 | MI.dump(); 106 | //BuildMI(MBB, MI, DL, TII->get(Z80::RCF)); 107 | //BuildMI(MBB, MI, DL, TII->get(Is24Bit ? Z80::SBC24ar : Z80::SBC16ar)) 108 | // .addReg(MI.getOperand(0).getReg()); 109 | //BuildMI(MBB, MI, DL, TII->get(Is24Bit ? Z80::ADD24ao : Z80::ADD16ao), 110 | // Is24Bit ? Z80::UHL : Z80::HL).addReg(Is24Bit ? Z80::UHL : Z80::HL) 111 | // .addReg(MI.getOperand(0).getReg()); 112 | } 113 | void Z80ExpandPseudo::ExpandCmp0(MachineInstr &MI, MachineBasicBlock &MBB) { 114 | bool Is24Bit = MI.getOpcode() == Z80::CP24a0; 115 | assert((Is24Bit || MI.getOpcode() == Z80::CP16a0) && "Unexpected opcode"); 116 | DebugLoc DL = MI.getDebugLoc(); 117 | dbgs() << "Z80ExpandPseudo::ExpandCmp"; 118 | MI.dump(); 119 | //BuildMI(MBB, MI, DL, TII->get(Is24Bit ? Z80::ADD24ao : Z80::ADD16ao), 120 | // Is24Bit ? Z80::UHL : Z80::HL).addReg(Is24Bit ? Z80::UHL : Z80::HL) 121 | // .addReg(MI.getOperand(0).getReg()); 122 | //BuildMI(MBB, MI, DL, TII->get(Z80::RCF)); 123 | //BuildMI(MBB, MI, DL, TII->get(Is24Bit ? Z80::SBC24ar : Z80::SBC16ar)) 124 | // .addReg(MI.getOperand(0).getReg()); 125 | } 126 | 127 | bool Z80ExpandPseudo::ExpandMI(MachineBasicBlock::iterator &MI, MachineBasicBlock &MBB) { 128 | switch (MI->getOpcode()) { 129 | default: return false; 130 | case Z80::CP16ao: 131 | case Z80::CP24ao: 132 | ExpandCmp(*MI, MBB); 133 | break; 134 | case Z80::CP16a0: 135 | case Z80::CP24a0: 136 | ExpandCmp0(*MI, MBB); 137 | break; 138 | } 139 | return false; 140 | MI = MBB.erase(MI); 141 | return true; 142 | } 143 | 144 | bool Z80ExpandPseudo::ExpandMBB(MachineBasicBlock &MBB) { 145 | bool Modified = false; 146 | for (auto I = MBB.begin(), E = MBB.end(); I != E; ++I) 147 | Modified |= ExpandMI(I, MBB); 148 | return Modified; 149 | } 150 | 151 | bool Z80ExpandPseudo::runOnMachineFunction(MachineFunction &MF) { 152 | getAnalysis().addKillFlags(&getAnalysis()); 153 | TII = MF.getSubtarget().getInstrInfo(); 154 | bool Modified = false; 155 | for (auto &MBB : MF) 156 | Modified |= ExpandMBB(MBB); 157 | return Modified; 158 | } 159 | -------------------------------------------------------------------------------- /tools/clang/include/clang/Basic/TargetBuiltins.h: -------------------------------------------------------------------------------- 1 | //===--- TargetBuiltins.h - Target specific builtin IDs ---------*- C++ -*-===// 2 | // 3 | // The LLVM Compiler Infrastructure 4 | // 5 | // This file is distributed under the University of Illinois Open Source 6 | // License. See LICENSE.TXT for details. 7 | // 8 | //===----------------------------------------------------------------------===// 9 | /// 10 | /// \file 11 | /// \brief Enumerates target-specific builtins in their own namespaces within 12 | /// namespace ::clang. 13 | /// 14 | //===----------------------------------------------------------------------===// 15 | 16 | #ifndef LLVM_CLANG_BASIC_TARGETBUILTINS_H 17 | #define LLVM_CLANG_BASIC_TARGETBUILTINS_H 18 | 19 | #include 20 | #include "clang/Basic/Builtins.h" 21 | #undef PPC 22 | 23 | namespace clang { 24 | 25 | namespace NEON { 26 | enum { 27 | LastTIBuiltin = clang::Builtin::FirstTSBuiltin - 1, 28 | #define BUILTIN(ID, TYPE, ATTRS) BI##ID, 29 | #include "clang/Basic/BuiltinsNEON.def" 30 | FirstTSBuiltin 31 | }; 32 | } 33 | 34 | /// \brief ARM builtins 35 | namespace ARM { 36 | enum { 37 | LastTIBuiltin = clang::Builtin::FirstTSBuiltin-1, 38 | LastNEONBuiltin = NEON::FirstTSBuiltin - 1, 39 | #define BUILTIN(ID, TYPE, ATTRS) BI##ID, 40 | #include "clang/Basic/BuiltinsARM.def" 41 | LastTSBuiltin 42 | }; 43 | } 44 | 45 | /// \brief AArch64 builtins 46 | namespace AArch64 { 47 | enum { 48 | LastTIBuiltin = clang::Builtin::FirstTSBuiltin - 1, 49 | LastNEONBuiltin = NEON::FirstTSBuiltin - 1, 50 | #define BUILTIN(ID, TYPE, ATTRS) BI##ID, 51 | #include "clang/Basic/BuiltinsAArch64.def" 52 | LastTSBuiltin 53 | }; 54 | } 55 | 56 | /// \brief PPC builtins 57 | namespace PPC { 58 | enum { 59 | LastTIBuiltin = clang::Builtin::FirstTSBuiltin-1, 60 | #define BUILTIN(ID, TYPE, ATTRS) BI##ID, 61 | #include "clang/Basic/BuiltinsPPC.def" 62 | LastTSBuiltin 63 | }; 64 | } 65 | 66 | /// \brief NVPTX builtins 67 | namespace NVPTX { 68 | enum { 69 | LastTIBuiltin = clang::Builtin::FirstTSBuiltin-1, 70 | #define BUILTIN(ID, TYPE, ATTRS) BI##ID, 71 | #include "clang/Basic/BuiltinsNVPTX.def" 72 | LastTSBuiltin 73 | }; 74 | } 75 | 76 | /// \brief AMDGPU builtins 77 | namespace AMDGPU { 78 | enum { 79 | LastTIBuiltin = clang::Builtin::FirstTSBuiltin - 1, 80 | #define BUILTIN(ID, TYPE, ATTRS) BI##ID, 81 | #include "clang/Basic/BuiltinsAMDGPU.def" 82 | LastTSBuiltin 83 | }; 84 | } 85 | 86 | /// \brief X86 builtins 87 | namespace X86 { 88 | enum { 89 | LastTIBuiltin = clang::Builtin::FirstTSBuiltin - 1, 90 | #define BUILTIN(ID, TYPE, ATTRS) BI##ID, 91 | #include "clang/Basic/BuiltinsX86.def" 92 | FirstX86_64Builtin, 93 | LastX86CommonBuiltin = FirstX86_64Builtin - 1, 94 | #define BUILTIN(ID, TYPE, ATTRS) BI##ID, 95 | #include "clang/Basic/BuiltinsX86_64.def" 96 | LastTSBuiltin 97 | }; 98 | } 99 | 100 | /// \brief Flags to identify the types for overloaded Neon builtins. 101 | /// 102 | /// These must be kept in sync with the flags in utils/TableGen/NeonEmitter.h. 103 | class NeonTypeFlags { 104 | enum { 105 | EltTypeMask = 0xf, 106 | UnsignedFlag = 0x10, 107 | QuadFlag = 0x20 108 | }; 109 | uint32_t Flags; 110 | 111 | public: 112 | enum EltType { 113 | Int8, 114 | Int16, 115 | Int32, 116 | Int64, 117 | Poly8, 118 | Poly16, 119 | Poly64, 120 | Poly128, 121 | Float16, 122 | Float32, 123 | Float64 124 | }; 125 | 126 | NeonTypeFlags(unsigned F) : Flags(F) {} 127 | NeonTypeFlags(EltType ET, bool IsUnsigned, bool IsQuad) : Flags(ET) { 128 | if (IsUnsigned) 129 | Flags |= UnsignedFlag; 130 | if (IsQuad) 131 | Flags |= QuadFlag; 132 | } 133 | 134 | EltType getEltType() const { return (EltType)(Flags & EltTypeMask); } 135 | bool isPoly() const { 136 | EltType ET = getEltType(); 137 | return ET == Poly8 || ET == Poly16; 138 | } 139 | bool isUnsigned() const { return (Flags & UnsignedFlag) != 0; } 140 | bool isQuad() const { return (Flags & QuadFlag) != 0; } 141 | }; 142 | 143 | /// \brief Hexagon builtins 144 | namespace Hexagon { 145 | enum { 146 | LastTIBuiltin = clang::Builtin::FirstTSBuiltin-1, 147 | #define BUILTIN(ID, TYPE, ATTRS) BI##ID, 148 | #include "clang/Basic/BuiltinsHexagon.def" 149 | LastTSBuiltin 150 | }; 151 | } 152 | 153 | /// \brief Nios2 builtins 154 | namespace Nios2 { 155 | enum { 156 | LastTIBuiltin = clang::Builtin::FirstTSBuiltin - 1, 157 | #define BUILTIN(ID, TYPE, ATTRS) BI##ID, 158 | #include "clang/Basic/BuiltinsNios2.def" 159 | LastTSBuiltin 160 | }; 161 | } 162 | 163 | /// \brief MIPS builtins 164 | namespace Mips { 165 | enum { 166 | LastTIBuiltin = clang::Builtin::FirstTSBuiltin-1, 167 | #define BUILTIN(ID, TYPE, ATTRS) BI##ID, 168 | #include "clang/Basic/BuiltinsMips.def" 169 | LastTSBuiltin 170 | }; 171 | } 172 | 173 | /// \brief XCore builtins 174 | namespace XCore { 175 | enum { 176 | LastTIBuiltin = clang::Builtin::FirstTSBuiltin-1, 177 | #define BUILTIN(ID, TYPE, ATTRS) BI##ID, 178 | #include "clang/Basic/BuiltinsXCore.def" 179 | LastTSBuiltin 180 | }; 181 | } 182 | 183 | /// \brief Le64 builtins 184 | namespace Le64 { 185 | enum { 186 | LastTIBuiltin = clang::Builtin::FirstTSBuiltin - 1, 187 | #define BUILTIN(ID, TYPE, ATTRS) BI##ID, 188 | #include "clang/Basic/BuiltinsLe64.def" 189 | LastTSBuiltin 190 | }; 191 | } 192 | 193 | /// \brief SystemZ builtins 194 | namespace SystemZ { 195 | enum { 196 | LastTIBuiltin = clang::Builtin::FirstTSBuiltin-1, 197 | #define BUILTIN(ID, TYPE, ATTRS) BI##ID, 198 | #include "clang/Basic/BuiltinsSystemZ.def" 199 | LastTSBuiltin 200 | }; 201 | } 202 | 203 | /// \brief WebAssembly builtins 204 | namespace WebAssembly { 205 | enum { 206 | LastTIBuiltin = clang::Builtin::FirstTSBuiltin-1, 207 | #define BUILTIN(ID, TYPE, ATTRS) BI##ID, 208 | #include "clang/Basic/BuiltinsWebAssembly.def" 209 | LastTSBuiltin 210 | }; 211 | } 212 | 213 | } // end namespace clang. 214 | 215 | #endif 216 | --------------------------------------------------------------------------------