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,6 +3,8 @@ 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) set(LLVM_TARGET_DEFINITIONS DXIL.td) tablegen(LLVM DXILOperation.inc -gen-dxil-operation) @@ -10,6 +12,8 @@ add_public_tablegen_target(DirectXCommonTableGen) add_llvm_target(DirectXCodeGen + DirectXInstrInfo.cpp + 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,18 @@ +// 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,35 @@ +//===-- 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 &, MachineBasicBlock &) const override {} + void emitEpilogue(MachineFunction &, MachineBasicBlock &) const override {} + + bool hasFP(const MachineFunction &) const override { return false; } +}; +} // namespace llvm +#endif // LLVM_DIRECTX_DIRECTXFRAMELOWERING_H diff --git a/llvm/lib/Target/DirectX/DirectXInstrInfo.h b/llvm/lib/Target/DirectX/DirectXInstrInfo.h new file mode 100644 --- /dev/null +++ b/llvm/lib/Target/DirectX/DirectXInstrInfo.h @@ -0,0 +1,30 @@ +//===-- DirectXInstrInfo.h - Define InstrInfo 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 TargetInstrInfo. +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DIRECTX_DIRECTXINSTRINFO_H +#define LLVM_DIRECTX_DIRECTXINSTRINFO_H + +#include "DirectXRegisterInfo.h" +#include "llvm/CodeGen/TargetInstrInfo.h" + +#define GET_INSTRINFO_HEADER +#include "DirectXGenInstrInfo.inc" + +namespace llvm { +struct DirectXInstrInfo : public DirectXGenInstrInfo { + explicit DirectXInstrInfo() : DirectXGenInstrInfo() {} + + ~DirectXInstrInfo() override; +}; +} // namespace llvm + +#endif // LLVM_DIRECTX_DIRECTXINSTRINFO_H diff --git a/llvm/lib/Target/DirectX/DirectXInstrInfo.cpp b/llvm/lib/Target/DirectX/DirectXInstrInfo.cpp new file mode 100644 --- /dev/null +++ b/llvm/lib/Target/DirectX/DirectXInstrInfo.cpp @@ -0,0 +1,20 @@ +//===-- DirectXInstrInfo.cpp - InstrInfo 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 TargetInstrInfo. +// +//===----------------------------------------------------------------------===// + +#include "DirectXInstrInfo.h" + +#define GET_INSTRINFO_CTOR_DTOR +#include "DirectXGenInstrInfo.inc" + +using namespace llvm; + +DirectXInstrInfo::~DirectXInstrInfo() {} 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(); +}; +} // 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,24 @@ +//===-- 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" + +using namespace llvm; + +DirectXRegisterInfo::~DirectXRegisterInfo() {} 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,29 @@ +//===- 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 + +// Include DirectX stub register info +#define GET_REGINFO_ENUM +#include "DirectXGenRegisterInfo.inc" + +// Include DirectX stub instruction info +#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