Re-commit AMDGPU/GlobalISel: Add support for simple shaders
Fix build when global-isel is disabled and fix a warning.
Summary: We can select constant/global G_LOAD, global G_STORE, and G_GEP.
Reviewers: qcolombet, MatzeB, t.p.northover, ab, arsenm
Subscribers: mehdi_amini, vkalintiris, kzhuravl, wdng, nhaehnle, mgorny, yaxunl, tony-tye, modocache, llvm-commits, dberris
Differential Revision: https://reviews.llvm.org/D26730
llvm-svn: 293551
2017-01-31 05:56:46 +08:00
|
|
|
//===- AMDGPULegalizerInfo.cpp -----------------------------------*- C++ -*-==//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
/// \file
|
|
|
|
/// This file implements the targeting of the Machinelegalizer class for
|
|
|
|
/// AMDGPU.
|
|
|
|
/// \todo This should be generated by TableGen.
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "AMDGPULegalizerInfo.h"
|
|
|
|
#include "llvm/CodeGen/ValueTypes.h"
|
|
|
|
#include "llvm/IR/DerivedTypes.h"
|
2017-06-06 19:49:48 +08:00
|
|
|
#include "llvm/IR/Type.h"
|
Re-commit AMDGPU/GlobalISel: Add support for simple shaders
Fix build when global-isel is disabled and fix a warning.
Summary: We can select constant/global G_LOAD, global G_STORE, and G_GEP.
Reviewers: qcolombet, MatzeB, t.p.northover, ab, arsenm
Subscribers: mehdi_amini, vkalintiris, kzhuravl, wdng, nhaehnle, mgorny, yaxunl, tony-tye, modocache, llvm-commits, dberris
Differential Revision: https://reviews.llvm.org/D26730
llvm-svn: 293551
2017-01-31 05:56:46 +08:00
|
|
|
#include "llvm/Support/Debug.h"
|
2017-06-06 19:49:48 +08:00
|
|
|
#include "llvm/Target/TargetOpcodes.h"
|
Re-commit AMDGPU/GlobalISel: Add support for simple shaders
Fix build when global-isel is disabled and fix a warning.
Summary: We can select constant/global G_LOAD, global G_STORE, and G_GEP.
Reviewers: qcolombet, MatzeB, t.p.northover, ab, arsenm
Subscribers: mehdi_amini, vkalintiris, kzhuravl, wdng, nhaehnle, mgorny, yaxunl, tony-tye, modocache, llvm-commits, dberris
Differential Revision: https://reviews.llvm.org/D26730
llvm-svn: 293551
2017-01-31 05:56:46 +08:00
|
|
|
|
|
|
|
using namespace llvm;
|
|
|
|
|
|
|
|
AMDGPULegalizerInfo::AMDGPULegalizerInfo() {
|
|
|
|
using namespace TargetOpcode;
|
|
|
|
|
AMDGPU/GlobalISel: Mark 1-bit integer constants as legal
Summary:
These are mostly legal, but will probably need special lowering for some
cases.
Reviewers: arsenm
Reviewed By: arsenm
Subscribers: kzhuravl, wdng, nhaehnle, yaxunl, rovka, kristof.beyls, igorb, dstuttard, tpr, llvm-commits, t-tye
Differential Revision: https://reviews.llvm.org/D33791
llvm-svn: 304628
2017-06-03 09:13:33 +08:00
|
|
|
const LLT S1= LLT::scalar(1);
|
AMDGPU/GlobalISel: Mark G_BITCAST s32 <--> <2 x s16> legal
Reviewers: arsenm
Reviewed By: arsenm
Subscribers: kzhuravl, wdng, nhaehnle, yaxunl, rovka, kristof.beyls, igorb, dstuttard, tpr, t-tye, llvm-commits
Differential Revision: https://reviews.llvm.org/D34129
llvm-svn: 305692
2017-06-19 21:15:45 +08:00
|
|
|
const LLT V2S16 = LLT::vector(2, 16);
|
Re-commit AMDGPU/GlobalISel: Add support for simple shaders
Fix build when global-isel is disabled and fix a warning.
Summary: We can select constant/global G_LOAD, global G_STORE, and G_GEP.
Reviewers: qcolombet, MatzeB, t.p.northover, ab, arsenm
Subscribers: mehdi_amini, vkalintiris, kzhuravl, wdng, nhaehnle, mgorny, yaxunl, tony-tye, modocache, llvm-commits, dberris
Differential Revision: https://reviews.llvm.org/D26730
llvm-svn: 293551
2017-01-31 05:56:46 +08:00
|
|
|
const LLT S32 = LLT::scalar(32);
|
|
|
|
const LLT S64 = LLT::scalar(64);
|
|
|
|
const LLT P1 = LLT::pointer(1, 64);
|
|
|
|
const LLT P2 = LLT::pointer(2, 64);
|
|
|
|
|
AMDGPU/GlobalISel: Mark 32-bit G_ADD as legal
Reviewers: arsenm
Reviewed By: arsenm
Subscribers: kzhuravl, wdng, nhaehnle, yaxunl, rovka, kristof.beyls, igorb, dstuttard, tpr, llvm-commits, t-tye
Differential Revision: https://reviews.llvm.org/D33992
llvm-svn: 305232
2017-06-13 04:54:56 +08:00
|
|
|
setAction({G_ADD, S32}, Legal);
|
AMDGPU/GlobalISel: Mark 32-bit G_AND as legal
Reviewers: arsenm
Reviewed By: arsenm
Subscribers: kzhuravl, wdng, nhaehnle, yaxunl, rovka, kristof.beyls, igorb, dstuttard, tpr, t-tye, llvm-commits
Differential Revision: https://reviews.llvm.org/D34349
llvm-svn: 306112
2017-06-23 23:17:17 +08:00
|
|
|
setAction({G_AND, S32}, Legal);
|
AMDGPU/GlobalISel: Mark 32-bit G_ADD as legal
Reviewers: arsenm
Reviewed By: arsenm
Subscribers: kzhuravl, wdng, nhaehnle, yaxunl, rovka, kristof.beyls, igorb, dstuttard, tpr, llvm-commits, t-tye
Differential Revision: https://reviews.llvm.org/D33992
llvm-svn: 305232
2017-06-13 04:54:56 +08:00
|
|
|
|
AMDGPU/GlobalISel: Mark G_BITCAST s32 <--> <2 x s16> legal
Reviewers: arsenm
Reviewed By: arsenm
Subscribers: kzhuravl, wdng, nhaehnle, yaxunl, rovka, kristof.beyls, igorb, dstuttard, tpr, t-tye, llvm-commits
Differential Revision: https://reviews.llvm.org/D34129
llvm-svn: 305692
2017-06-19 21:15:45 +08:00
|
|
|
setAction({G_BITCAST, V2S16}, Legal);
|
|
|
|
setAction({G_BITCAST, 1, S32}, Legal);
|
|
|
|
|
|
|
|
setAction({G_BITCAST, S32}, Legal);
|
|
|
|
setAction({G_BITCAST, 1, V2S16}, Legal);
|
|
|
|
|
AMDGPU/GlobalISel: Mark 1-bit integer constants as legal
Summary:
These are mostly legal, but will probably need special lowering for some
cases.
Reviewers: arsenm
Reviewed By: arsenm
Subscribers: kzhuravl, wdng, nhaehnle, yaxunl, rovka, kristof.beyls, igorb, dstuttard, tpr, llvm-commits, t-tye
Differential Revision: https://reviews.llvm.org/D33791
llvm-svn: 304628
2017-06-03 09:13:33 +08:00
|
|
|
// FIXME: i1 operands to intrinsics should always be legal, but other i1
|
|
|
|
// values may not be legal. We need to figure out how to distinguish
|
|
|
|
// between these two scenarios.
|
|
|
|
setAction({G_CONSTANT, S1}, Legal);
|
AMDGPU/GlobalISel: Mark 32-bit integer constants as legal
Reviewers: arsenm
Reviewed By: arsenm
Subscribers: kzhuravl, wdng, nhaehnle, yaxunl, rovka, kristof.beyls, igorb, dstuttard, tpr, t-tye, llvm-commits
Differential Revision: https://reviews.llvm.org/D33115
llvm-svn: 302919
2017-05-13 00:46:46 +08:00
|
|
|
setAction({G_CONSTANT, S32}, Legal);
|
Re-commit AMDGPU/GlobalISel: Add support for simple shaders
Fix build when global-isel is disabled and fix a warning.
Summary: We can select constant/global G_LOAD, global G_STORE, and G_GEP.
Reviewers: qcolombet, MatzeB, t.p.northover, ab, arsenm
Subscribers: mehdi_amini, vkalintiris, kzhuravl, wdng, nhaehnle, mgorny, yaxunl, tony-tye, modocache, llvm-commits, dberris
Differential Revision: https://reviews.llvm.org/D26730
llvm-svn: 293551
2017-01-31 05:56:46 +08:00
|
|
|
setAction({G_CONSTANT, S64}, Legal);
|
|
|
|
|
AMDGPU/GlobalISel: Mark 32-bit float constants as legal
Reviewers: arsenm
Reviewed By: arsenm
Subscribers: kzhuravl, wdng, nhaehnle, yaxunl, rovka, kristof.beyls, igorb, dstuttard, tpr, t-tye, llvm-commits
Differential Revision: https://reviews.llvm.org/D33212
llvm-svn: 304003
2017-05-27 00:40:03 +08:00
|
|
|
setAction({G_FCONSTANT, S32}, Legal);
|
|
|
|
|
AMDGPU/GlobalISel: Mark 32-bit G_FADD as legal
Reviewers: arsenm
Reviewed By: arsenm
Subscribers: kzhuravl, wdng, nhaehnle, yaxunl, rovka, kristof.beyls, igorb, dstuttard, tpr, t-tye, llvm-commits
Differential Revision: https://reviews.llvm.org/D38439
llvm-svn: 316815
2017-10-28 07:57:41 +08:00
|
|
|
setAction({G_FADD, S32}, Legal);
|
|
|
|
|
AMDGPU/GlobalISel: Mark 32-bit G_FMUL as legal
Reviewers: arsenm
Reviewed By: arsenm
Subscribers: kzhuravl, wdng, nhaehnle, yaxunl, rovka, kristof.beyls, igorb, dstuttard, tpr, llvm-commits, t-tye
Differential Revision: https://reviews.llvm.org/D36218
llvm-svn: 309898
2017-08-03 06:56:30 +08:00
|
|
|
setAction({G_FMUL, S32}, Legal);
|
|
|
|
|
Re-commit AMDGPU/GlobalISel: Add support for simple shaders
Fix build when global-isel is disabled and fix a warning.
Summary: We can select constant/global G_LOAD, global G_STORE, and G_GEP.
Reviewers: qcolombet, MatzeB, t.p.northover, ab, arsenm
Subscribers: mehdi_amini, vkalintiris, kzhuravl, wdng, nhaehnle, mgorny, yaxunl, tony-tye, modocache, llvm-commits, dberris
Differential Revision: https://reviews.llvm.org/D26730
llvm-svn: 293551
2017-01-31 05:56:46 +08:00
|
|
|
setAction({G_GEP, P1}, Legal);
|
|
|
|
setAction({G_GEP, P2}, Legal);
|
|
|
|
setAction({G_GEP, 1, S64}, Legal);
|
|
|
|
|
AMDGPU/GlobalISel: Mark 32-bit G_ICMP as legal
Reviewers: arsenm
Reviewed By: arsenm
Subscribers: kzhuravl, wdng, nhaehnle, yaxunl, rovka, kristof.beyls, igorb, dstuttard, tpr, t-tye, llvm-commits
Differential Revision: https://reviews.llvm.org/D33890
llvm-svn: 304797
2017-06-06 22:16:50 +08:00
|
|
|
setAction({G_ICMP, S1}, Legal);
|
|
|
|
setAction({G_ICMP, 1, S32}, Legal);
|
|
|
|
|
Re-commit AMDGPU/GlobalISel: Add support for simple shaders
Fix build when global-isel is disabled and fix a warning.
Summary: We can select constant/global G_LOAD, global G_STORE, and G_GEP.
Reviewers: qcolombet, MatzeB, t.p.northover, ab, arsenm
Subscribers: mehdi_amini, vkalintiris, kzhuravl, wdng, nhaehnle, mgorny, yaxunl, tony-tye, modocache, llvm-commits, dberris
Differential Revision: https://reviews.llvm.org/D26730
llvm-svn: 293551
2017-01-31 05:56:46 +08:00
|
|
|
setAction({G_LOAD, P1}, Legal);
|
|
|
|
setAction({G_LOAD, P2}, Legal);
|
|
|
|
setAction({G_LOAD, S32}, Legal);
|
|
|
|
setAction({G_LOAD, 1, P1}, Legal);
|
|
|
|
setAction({G_LOAD, 1, P2}, Legal);
|
|
|
|
|
AMDGPU/GlobalISel: Mark 32-bit G_OR as legal
Reviewers: arsenm
Reviewed By: arsenm
Subscribers: kzhuravl, wdng, nhaehnle, yaxunl, rovka, kristof.beyls, igorb, dstuttard, tpr, t-tye, llvm-commits
Differential Revision: https://reviews.llvm.org/D35127
llvm-svn: 309165
2017-07-27 04:00:53 +08:00
|
|
|
setAction({G_OR, S32}, Legal);
|
|
|
|
|
AMDGPU/GlobalISel: Mark 32-bit G_SELECT as legal
Reviewers: arsenm
Reviewed By: arsenm
Subscribers: kzhuravl, wdng, nhaehnle, yaxunl, rovka, kristof.beyls, igorb, dstuttard, tpr, t-tye, llvm-commits
Differential Revision: https://reviews.llvm.org/D33949
llvm-svn: 304910
2017-06-07 21:54:51 +08:00
|
|
|
setAction({G_SELECT, S32}, Legal);
|
|
|
|
setAction({G_SELECT, 1, S1}, Legal);
|
|
|
|
|
AMDGPU/GlobalISel: Mark 32-bit G_SHL as legal
Reviewers: arsenm
Reviewed By: arsenm
Subscribers: kzhuravl, wdng, nhaehnle, yaxunl, rovka, kristof.beyls, igorb, dstuttard, tpr, t-tye, llvm-commits
Differential Revision: https://reviews.llvm.org/D34589
llvm-svn: 306298
2017-06-26 23:56:52 +08:00
|
|
|
setAction({G_SHL, S32}, Legal);
|
|
|
|
|
Re-commit AMDGPU/GlobalISel: Add support for simple shaders
Fix build when global-isel is disabled and fix a warning.
Summary: We can select constant/global G_LOAD, global G_STORE, and G_GEP.
Reviewers: qcolombet, MatzeB, t.p.northover, ab, arsenm
Subscribers: mehdi_amini, vkalintiris, kzhuravl, wdng, nhaehnle, mgorny, yaxunl, tony-tye, modocache, llvm-commits, dberris
Differential Revision: https://reviews.llvm.org/D26730
llvm-svn: 293551
2017-01-31 05:56:46 +08:00
|
|
|
setAction({G_STORE, S32}, Legal);
|
|
|
|
setAction({G_STORE, 1, P1}, Legal);
|
|
|
|
|
|
|
|
// FIXME: When RegBankSelect inserts copies, it will only create new
|
|
|
|
// registers with scalar types. This means we can end up with
|
|
|
|
// G_LOAD/G_STORE/G_GEP instruction with scalar types for their pointer
|
|
|
|
// operands. In assert builds, the instruction selector will assert
|
|
|
|
// if it sees a generic instruction which isn't legal, so we need to
|
|
|
|
// tell it that scalar types are legal for pointer operands
|
|
|
|
setAction({G_GEP, S64}, Legal);
|
|
|
|
setAction({G_LOAD, 1, S64}, Legal);
|
|
|
|
setAction({G_STORE, 1, S64}, Legal);
|
|
|
|
|
|
|
|
computeTables();
|
|
|
|
}
|