diff --git a/llvm/lib/Target/DirectX/CMakeLists.txt b/llvm/lib/Target/DirectX/CMakeLists.txt --- a/llvm/lib/Target/DirectX/CMakeLists.txt +++ b/llvm/lib/Target/DirectX/CMakeLists.txt @@ -3,10 +3,13 @@ set(LLVM_TARGET_DEFINITIONS DirectX.td) tablegen(LLVM DirectXGenSubtargetInfo.inc -gen-subtarget) +tablegen(LLVM DirectXGenInstrInfo.inc -gen-instr-info) +tablegen(LLVM DirectXGenRegisterInfo.inc -gen-register-info) add_public_tablegen_target(DirectXCommonTableGen) add_llvm_target(DirectXCodeGen + DirectXRegisterInfo.cpp DirectXSubtarget.cpp DirectXTargetMachine.cpp DXILOpLowering.cpp diff --git a/llvm/lib/Target/DirectX/DXILStubs.td b/llvm/lib/Target/DirectX/DXILStubs.td new file mode 100644 --- /dev/null +++ b/llvm/lib/Target/DirectX/DXILStubs.td @@ -0,0 +1,20 @@ +// DXIL doesn't actually use registers, but this gets the boilerplate code +// generated through tablegen. +let Namespace = "DXIL" in { +def DXIL : Register<"DXIL">; +def DXILClass : RegisterClass<"DXIL", [i32], 32, (add DXIL)>; +} + +class DXILInst + : Instruction { + + let Namespace = "DXIL"; + let DecoderNamespace = "DXIL"; + + dag OutOperandList = (outs); + dag InOperandList = (ins); + let AsmString = "dummy"; + let Pattern = []; +} + +def DummyInst : DXILInst; diff --git a/llvm/lib/Target/DirectX/DirectX.td b/llvm/lib/Target/DirectX/DirectX.td --- a/llvm/lib/Target/DirectX/DirectX.td +++ b/llvm/lib/Target/DirectX/DirectX.td @@ -16,6 +16,7 @@ //===----------------------------------------------------------------------===// include "llvm/Target/Target.td" +include "DXILStubs.td" //===----------------------------------------------------------------------===// // DirectX Subtarget features. diff --git a/llvm/lib/Target/DirectX/DirectXFrameLowering.h b/llvm/lib/Target/DirectX/DirectXFrameLowering.h new file mode 100644 --- /dev/null +++ b/llvm/lib/Target/DirectX/DirectXFrameLowering.h @@ -0,0 +1,37 @@ +//===-- DirectXFrameLowering.h - Frame lowering for DirectX --*- C++ ---*--===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// +// +// This class implements DirectX-specific bits of TargetFrameLowering class. +// This is just a stub because the current DXIL backend does not actually lower +// through the MC layer. +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DIRECTX_DIRECTXFRAMELOWERING_H +#define LLVM_DIRECTX_DIRECTXFRAMELOWERING_H + +#include "llvm/CodeGen/TargetFrameLowering.h" +#include "llvm/Support/Alignment.h" + +namespace llvm { +class DirectXSubtarget; + +class DirectXFrameLowering : public TargetFrameLowering { +public: + explicit DirectXFrameLowering(const DirectXSubtarget &STI) + : TargetFrameLowering(TargetFrameLowering::StackGrowsDown, Align(8), 0) {} + + void emitPrologue(MachineFunction &MF, + MachineBasicBlock &MBB) const override {} + void emitEpilogue(MachineFunction &MF, + MachineBasicBlock &MBB) const override {} + + bool hasFP(const MachineFunction &MF) const override { return false; } +}; +} // namespace llvm +#endif // LLVM_DIRECTX_DIRECTXFRAMELOWERING_H diff --git a/llvm/lib/Target/DirectX/DirectXRegisterInfo.h b/llvm/lib/Target/DirectX/DirectXRegisterInfo.h new file mode 100644 --- /dev/null +++ b/llvm/lib/Target/DirectX/DirectXRegisterInfo.h @@ -0,0 +1,28 @@ +//===-- DirectXRegisterInfo.h - Define RegisterInfo for DirectX -*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// +// +// This file declares the DirectX specific subclass of TargetRegisterInfo. +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DIRECTX_DXILREGISTERINFO_H +#define LLVM_DIRECTX_DXILREGISTERINFO_H + +#include "llvm/CodeGen/TargetRegisterInfo.h" + +#define GET_REGINFO_HEADER +#include "DirectXGenRegisterInfo.inc" + +namespace llvm { +struct DirectXRegisterInfo : public DirectXGenRegisterInfo { + DirectXRegisterInfo() : DirectXGenRegisterInfo(0) {} + ~DirectXRegisterInfo() override = default; +}; +} // namespace llvm + +#endif // LLVM_DIRECTX_DXILREGISTERINFO_H diff --git a/llvm/lib/Target/DirectX/DirectXRegisterInfo.cpp b/llvm/lib/Target/DirectX/DirectXRegisterInfo.cpp new file mode 100644 --- /dev/null +++ b/llvm/lib/Target/DirectX/DirectXRegisterInfo.cpp @@ -0,0 +1,20 @@ +//===-- DirectXRegisterInfo.cpp - RegisterInfo for DirectX -*- C++ ------*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// +// +// This file defines the DirectX specific subclass of TargetRegisterInfo. +// +//===----------------------------------------------------------------------===// + +#include "DirectXRegisterInfo.h" +#include "DirectXFrameLowering.h" +#include "MCTargetDesc/DirectXMCTargetDesc.h" +#include "llvm/CodeGen/MachineFunction.h" +#include "llvm/CodeGen/TargetSubtargetInfo.h" + +#define GET_REGINFO_TARGET_DESC +#include "DirectXGenRegisterInfo.inc" diff --git a/llvm/lib/Target/DirectX/MCTargetDesc/DirectXMCTargetDesc.h b/llvm/lib/Target/DirectX/MCTargetDesc/DirectXMCTargetDesc.h new file mode 100644 --- /dev/null +++ b/llvm/lib/Target/DirectX/MCTargetDesc/DirectXMCTargetDesc.h @@ -0,0 +1,32 @@ +//===- DirectXMCTargetDesc.h - DirectX Target Interface ---------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// +/// +/// \file +/// This file contains DirectX target interface. +/// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DIRECTX_DIRECTXMCTARGETDESC_H +#define LLVM_DIRECTX_DIRECTXMCTARGETDESC_H + +// Defines symbolic names for AArch64 registers. This defines a mapping from +// register name to register number. +// +#define GET_REGINFO_ENUM +#include "DirectXGenRegisterInfo.inc" + +// Defines symbolic names for the AArch64 instructions. +// +#define GET_INSTRINFO_ENUM +#define GET_INSTRINFO_MC_HELPER_DECLS +#include "DirectXGenInstrInfo.inc" + +#define GET_SUBTARGETINFO_ENUM +#include "DirectXGenSubtargetInfo.inc" + +#endif // LLVM_DIRECTX_DIRECTXMCTARGETDESC_H