From b91e88a9a61970c6d43622f2558b5780f5fc7a84 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Mon, 9 Jan 2017 11:25:21 +0100 Subject: [PATCH] Remove unused intrinsic functions --- tools/drawergen/ssa/ssa_float.cpp | 81 ------------------------------- tools/drawergen/ssa/ssa_float.h | 10 ---- tools/drawergen/ssa/ssa_vec4f.cpp | 65 ------------------------- tools/drawergen/ssa/ssa_vec4f.h | 8 --- tools/drawergen/ssa/ssa_vec4i.cpp | 11 ++--- tools/drawergen/ssa/ssa_vec4i.h | 1 - tools/drawergen/ssa/ssa_vec8s.cpp | 24 +-------- tools/drawergen/ssa/ssa_vec8s.h | 2 - 8 files changed, 4 insertions(+), 198 deletions(-) diff --git a/tools/drawergen/ssa/ssa_float.cpp b/tools/drawergen/ssa/ssa_float.cpp index f537792fc9..4f93379c89 100644 --- a/tools/drawergen/ssa/ssa_float.cpp +++ b/tools/drawergen/ssa/ssa_float.cpp @@ -54,18 +54,6 @@ llvm::Type *SSAFloat::llvm_type() return llvm::Type::getFloatTy(SSAScope::context()); } -SSAFloat SSAFloat::sqrt(SSAFloat f) -{ - std::vector params; - params.push_back(SSAFloat::llvm_type()); - return SSAFloat::from_llvm(SSAScope::builder().CreateCall(SSAScope::intrinsic(llvm::Intrinsic::sqrt, params), f.v, SSAScope::hint())); -} - -SSAFloat SSAFloat::fastsqrt(SSAFloat f) -{ - return f * rsqrt(f); -} - SSAFloat SSAFloat::rsqrt(SSAFloat f) { llvm::Value *f_ss = SSAScope::builder().CreateInsertElement(llvm::UndefValue::get(SSAVec4f::llvm_type()), f.v, llvm::ConstantInt::get(SSAScope::context(), llvm::APInt(32, (uint64_t)0))); @@ -73,75 +61,6 @@ SSAFloat SSAFloat::rsqrt(SSAFloat f) return SSAFloat::from_llvm(SSAScope::builder().CreateExtractElement(f_ss, SSAInt(0).v, SSAScope::hint())); } -SSAFloat SSAFloat::sin(SSAFloat val) -{ - std::vector params; - params.push_back(SSAFloat::llvm_type()); - return SSAFloat::from_llvm(SSAScope::builder().CreateCall(SSAScope::intrinsic(llvm::Intrinsic::sin, params), val.v, SSAScope::hint())); -} - -SSAFloat SSAFloat::cos(SSAFloat val) -{ - std::vector params; - params.push_back(SSAFloat::llvm_type()); - return SSAFloat::from_llvm(SSAScope::builder().CreateCall(SSAScope::intrinsic(llvm::Intrinsic::cos, params), val.v, SSAScope::hint())); -} - -SSAFloat SSAFloat::pow(SSAFloat val, SSAFloat power) -{ - std::vector params; - params.push_back(SSAFloat::llvm_type()); - //params.push_back(SSAFloat::llvm_type()); - std::vector args; - args.push_back(val.v); - args.push_back(power.v); - return SSAFloat::from_llvm(SSAScope::builder().CreateCall(SSAScope::intrinsic(llvm::Intrinsic::pow, params), args, SSAScope::hint())); -} - -SSAFloat SSAFloat::exp(SSAFloat val) -{ - std::vector params; - params.push_back(SSAFloat::llvm_type()); - return SSAFloat::from_llvm(SSAScope::builder().CreateCall(SSAScope::intrinsic(llvm::Intrinsic::exp, params), val.v, SSAScope::hint())); -} - -SSAFloat SSAFloat::log(SSAFloat val) -{ - std::vector params; - params.push_back(SSAFloat::llvm_type()); - return SSAFloat::from_llvm(SSAScope::builder().CreateCall(SSAScope::intrinsic(llvm::Intrinsic::log, params), val.v, SSAScope::hint())); -} - -SSAFloat SSAFloat::fma(SSAFloat a, SSAFloat b, SSAFloat c) -{ - std::vector params; - params.push_back(SSAFloat::llvm_type()); - //params.push_back(SSAFloat::llvm_type()); - //params.push_back(SSAFloat::llvm_type()); - std::vector args; - args.push_back(a.v); - args.push_back(b.v); - args.push_back(c.v); - return SSAFloat::from_llvm(SSAScope::builder().CreateCall(SSAScope::intrinsic(llvm::Intrinsic::fma, params), args, SSAScope::hint())); -} - -/* This intrinsic isn't always available.. -SSAFloat SSAFloat::round(SSAFloat val) -{ - - std::vector params; - params.push_back(SSAFloat::llvm_type()); - return SSAFloat::from_llvm(SSAScope::builder().CreateCall(SSAScope::intrinsic(llvm::Intrinsic::round, params), val.v, SSAScope::hint())); -} -*/ - -SSAFloat SSAFloat::floor(SSAFloat val) -{ - std::vector params; - params.push_back(SSAFloat::llvm_type()); - return SSAFloat::from_llvm(SSAScope::builder().CreateCall(SSAScope::intrinsic(llvm::Intrinsic::floor, params), val.v, SSAScope::hint())); -} - SSAFloat SSAFloat::MIN(SSAFloat a, SSAFloat b) { return SSAFloat::from_llvm(SSAScope::builder().CreateSelect((a < b).v, a.v, b.v, SSAScope::hint())); diff --git a/tools/drawergen/ssa/ssa_float.h b/tools/drawergen/ssa/ssa_float.h index f7e2b93ef9..b3a35486f3 100644 --- a/tools/drawergen/ssa/ssa_float.h +++ b/tools/drawergen/ssa/ssa_float.h @@ -36,17 +36,7 @@ public: explicit SSAFloat(llvm::Value *v); static SSAFloat from_llvm(llvm::Value *v) { return SSAFloat(v); } static llvm::Type *llvm_type(); - static SSAFloat sqrt(SSAFloat f); - static SSAFloat fastsqrt(SSAFloat f); static SSAFloat rsqrt(SSAFloat f); - static SSAFloat sin(SSAFloat val); - static SSAFloat cos(SSAFloat val); - static SSAFloat pow(SSAFloat val, SSAFloat power); - static SSAFloat exp(SSAFloat val); - static SSAFloat log(SSAFloat val); - static SSAFloat fma(SSAFloat a, SSAFloat b, SSAFloat c); - //static SSAFloat round(SSAFloat val); - static SSAFloat floor(SSAFloat val); static SSAFloat MIN(SSAFloat a, SSAFloat b); static SSAFloat MAX(SSAFloat a, SSAFloat b); static SSAFloat clamp(SSAFloat a, SSAFloat b, SSAFloat c); diff --git a/tools/drawergen/ssa/ssa_vec4f.cpp b/tools/drawergen/ssa/ssa_vec4f.cpp index 5c40f74940..e58f167de6 100644 --- a/tools/drawergen/ssa/ssa_vec4f.cpp +++ b/tools/drawergen/ssa/ssa_vec4f.cpp @@ -111,71 +111,6 @@ SSAVec4f SSAVec4f::bitcast(SSAVec4i i32) return SSAVec4i::from_llvm(SSAScope::builder().CreateBitCast(i32.v, llvm_type(), SSAScope::hint())); } -SSAVec4f SSAVec4f::sqrt(SSAVec4f f) -{ - std::vector params; - params.push_back(SSAVec4f::llvm_type()); - return SSAFloat::from_llvm(SSAScope::builder().CreateCall(SSAScope::intrinsic(llvm::Intrinsic::sqrt, params), f.v, SSAScope::hint())); - //return SSAVec4f::from_llvm(SSAScope::builder().CreateCall(SSAScope::intrinsic(llvm::Intrinsic::x86_sse_sqrt_ps), f.v, SSAScope::hint())); -} - -SSAVec4f SSAVec4f::rcp(SSAVec4f f) -{ - return SSAVec4f::from_llvm(SSAScope::builder().CreateCall(SSAScope::intrinsic(llvm::Intrinsic::x86_sse_rcp_ps), f.v, SSAScope::hint())); -} - -SSAVec4f SSAVec4f::sin(SSAVec4f val) -{ - std::vector params; - params.push_back(SSAVec4f::llvm_type()); - return SSAFloat::from_llvm(SSAScope::builder().CreateCall(SSAScope::intrinsic(llvm::Intrinsic::sin, params), val.v, SSAScope::hint())); -} - -SSAVec4f SSAVec4f::cos(SSAVec4f val) -{ - std::vector params; - params.push_back(SSAVec4f::llvm_type()); - return SSAFloat::from_llvm(SSAScope::builder().CreateCall(SSAScope::intrinsic(llvm::Intrinsic::cos, params), val.v, SSAScope::hint())); -} - -SSAVec4f SSAVec4f::pow(SSAVec4f val, SSAVec4f power) -{ - std::vector params; - params.push_back(SSAVec4f::llvm_type()); - //params.push_back(SSAVec4f::llvm_type()); - std::vector args; - args.push_back(val.v); - args.push_back(power.v); - return SSAFloat::from_llvm(SSAScope::builder().CreateCall(SSAScope::intrinsic(llvm::Intrinsic::pow, params), args, SSAScope::hint())); -} - -SSAVec4f SSAVec4f::exp(SSAVec4f val) -{ - std::vector params; - params.push_back(SSAVec4f::llvm_type()); - return SSAFloat::from_llvm(SSAScope::builder().CreateCall(SSAScope::intrinsic(llvm::Intrinsic::exp, params), val.v, SSAScope::hint())); -} - -SSAVec4f SSAVec4f::log(SSAVec4f val) -{ - std::vector params; - params.push_back(SSAVec4f::llvm_type()); - return SSAFloat::from_llvm(SSAScope::builder().CreateCall(SSAScope::intrinsic(llvm::Intrinsic::log, params), val.v, SSAScope::hint())); -} - -SSAVec4f SSAVec4f::fma(SSAVec4f a, SSAVec4f b, SSAVec4f c) -{ - std::vector params; - params.push_back(SSAVec4f::llvm_type()); - //params.push_back(SSAVec4f::llvm_type()); - //params.push_back(SSAVec4f::llvm_type()); - std::vector args; - args.push_back(a.v); - args.push_back(b.v); - args.push_back(c.v); - return SSAFloat::from_llvm(SSAScope::builder().CreateCall(SSAScope::intrinsic(llvm::Intrinsic::fma, params), args, SSAScope::hint())); -} - void SSAVec4f::transpose(SSAVec4f &row0, SSAVec4f &row1, SSAVec4f &row2, SSAVec4f &row3) { SSAVec4f tmp0 = shuffle(row0, row1, 0x44);//_MM_SHUFFLE(1,0,1,0)); diff --git a/tools/drawergen/ssa/ssa_vec4f.h b/tools/drawergen/ssa/ssa_vec4f.h index d8a2c5d012..3011da9d00 100644 --- a/tools/drawergen/ssa/ssa_vec4f.h +++ b/tools/drawergen/ssa/ssa_vec4f.h @@ -43,14 +43,6 @@ public: SSAFloat operator[](int index) const; static SSAVec4f insert_element(SSAVec4f vec4f, SSAFloat value, int index); static SSAVec4f bitcast(SSAVec4i i32); - static SSAVec4f sqrt(SSAVec4f f); - static SSAVec4f rcp(SSAVec4f f); - static SSAVec4f sin(SSAVec4f val); - static SSAVec4f cos(SSAVec4f val); - static SSAVec4f pow(SSAVec4f val, SSAVec4f power); - static SSAVec4f exp(SSAVec4f val); - static SSAVec4f log(SSAVec4f val); - static SSAVec4f fma(SSAVec4f a, SSAVec4f b, SSAVec4f c); static void transpose(SSAVec4f &row0, SSAVec4f &row1, SSAVec4f &row2, SSAVec4f &row3); static SSAVec4f shuffle(const SSAVec4f &f0, int index0, int index1, int index2, int index3); static SSAVec4f shuffle(const SSAVec4f &f0, const SSAVec4f &f1, int index0, int index1, int index2, int index3); diff --git a/tools/drawergen/ssa/ssa_vec4i.cpp b/tools/drawergen/ssa/ssa_vec4i.cpp index 344b33e1ee..0e42124e94 100644 --- a/tools/drawergen/ssa/ssa_vec4i.cpp +++ b/tools/drawergen/ssa/ssa_vec4i.cpp @@ -89,11 +89,13 @@ SSAVec4i::SSAVec4i(SSAInt i0, SSAInt i1, SSAInt i2, SSAInt i3) #endif } +/* SSAVec4i::SSAVec4i(SSAVec4f f32) : v(0) { v = SSAScope::builder().CreateCall(SSAScope::intrinsic(llvm::Intrinsic::x86_sse2_cvttps2dq), f32.v, SSAScope::hint()); } +*/ SSAInt SSAVec4i::operator[](SSAInt index) const { @@ -198,11 +200,6 @@ SSAVec4i SSAVec4i::combinelo(SSAVec8s a, SSAVec8s b) return SSAVec4i::bitcast(SSAVec8s::shuffle(a, b, 0, 8+0, 1, 8+1, 2, 8+2, 3, 8+3)); // _mm_unpacklo_epi16 } -SSAVec4i SSAVec4i::sqrt(SSAVec4i f) -{ - return SSAVec4i::from_llvm(SSAScope::builder().CreateCall(SSAScope::intrinsic(llvm::Intrinsic::x86_sse2_sqrt_pd), f.v, SSAScope::hint())); -} - SSAVec4i operator+(const SSAVec4i &a, const SSAVec4i &b) { return SSAVec4i::from_llvm(SSAScope::builder().CreateAdd(a.v, b.v, SSAScope::hint())); @@ -265,9 +262,7 @@ SSAVec4i operator/(const SSAVec4i &a, int b) SSAVec4i operator<<(const SSAVec4i &a, int bits) { - //return SSAScope::builder().CreateShl(a.v, bits); - llvm::Value *values[2] = { a.v, llvm::ConstantInt::get(SSAScope::context(), llvm::APInt(32, (uint64_t)bits)) }; - return SSAVec4i::from_llvm(SSAScope::builder().CreateCall(SSAScope::intrinsic(llvm::Intrinsic::x86_sse2_pslli_d), values, SSAScope::hint())); + return SSAInt::from_llvm(SSAScope::builder().CreateShl(a.v, bits, SSAScope::hint())); } SSAVec4i operator>>(const SSAVec4i &a, int bits) diff --git a/tools/drawergen/ssa/ssa_vec4i.h b/tools/drawergen/ssa/ssa_vec4i.h index 2035b54572..e8a3ec9a5a 100644 --- a/tools/drawergen/ssa/ssa_vec4i.h +++ b/tools/drawergen/ssa/ssa_vec4i.h @@ -55,7 +55,6 @@ public: static void extend(SSAVec16ub a, SSAVec4i &out0, SSAVec4i &out1, SSAVec4i &out2, SSAVec4i &out3); static SSAVec4i combinehi(SSAVec8s v0, SSAVec8s v1); static SSAVec4i combinelo(SSAVec8s v0, SSAVec8s v1); - static SSAVec4i sqrt(SSAVec4i f); static SSAVec4i from_llvm(llvm::Value *v) { return SSAVec4i(v); } static llvm::Type *llvm_type(); diff --git a/tools/drawergen/ssa/ssa_vec8s.cpp b/tools/drawergen/ssa/ssa_vec8s.cpp index 0950a289e5..552b8d69b5 100644 --- a/tools/drawergen/ssa/ssa_vec8s.cpp +++ b/tools/drawergen/ssa/ssa_vec8s.cpp @@ -106,26 +106,6 @@ SSAVec8s SSAVec8s::extendlo(SSAVec16ub a) return SSAVec8s::bitcast(SSAVec16ub::shuffle(a, SSAVec16ub((unsigned char)0), 0, 16+0, 1, 16+1, 2, 16+2, 3, 16+3, 4, 16+4, 5, 16+5, 6, 16+6, 7, 16+7)); // _mm_unpacklo_epi8 } -/* -SSAVec8s SSAVec8s::min_sse2(SSAVec8s a, SSAVec8s b) -{ - llvm::Value *values[2] = { a.v, b.v }; - return SSAVec8s::from_llvm(SSAScope::builder().CreateCall(SSAScope::intrinsic(llvm::Intrinsic::x86_sse2_pmins_w), values, SSAScope::hint())); -} - -SSAVec8s SSAVec8s::max_sse2(SSAVec8s a, SSAVec8s b) -{ - llvm::Value *values[2] = { a.v, b.v }; - return SSAVec8s::from_llvm(SSAScope::builder().CreateCall(SSAScope::intrinsic(llvm::Intrinsic::x86_sse2_pmaxs_w), values, SSAScope::hint())); -} -*/ - -SSAVec8s SSAVec8s::mulhi(SSAVec8s a, SSAVec8s b) -{ - llvm::Value *values[2] = { a.v, b.v }; - return SSAVec8s::from_llvm(SSAScope::builder().CreateCall(SSAScope::intrinsic(llvm::Intrinsic::x86_sse2_pmulh_w), values, SSAScope::hint())); -} - SSAVec8s operator+(const SSAVec8s &a, const SSAVec8s &b) { return SSAVec8s::from_llvm(SSAScope::builder().CreateAdd(a.v, b.v, SSAScope::hint())); @@ -188,9 +168,7 @@ SSAVec8s operator/(const SSAVec8s &a, short b) SSAVec8s operator<<(const SSAVec8s &a, int bits) { - //return SSAScope::builder().CreateShl(a.v, bits); - llvm::Value *values[2] = { a.v, llvm::ConstantInt::get(SSAScope::context(), llvm::APInt(32, (uint64_t)bits)) }; - return SSAVec8s::from_llvm(SSAScope::builder().CreateCall(SSAScope::intrinsic(llvm::Intrinsic::x86_sse2_pslli_d), values, SSAScope::hint())); + return SSAVec8s::from_llvm(SSAScope::builder().CreateShl(a.v, bits, SSAScope::hint())); } SSAVec8s operator>>(const SSAVec8s &a, int bits) diff --git a/tools/drawergen/ssa/ssa_vec8s.h b/tools/drawergen/ssa/ssa_vec8s.h index be320804ec..fdd56d972a 100644 --- a/tools/drawergen/ssa/ssa_vec8s.h +++ b/tools/drawergen/ssa/ssa_vec8s.h @@ -41,8 +41,6 @@ public: static SSAVec8s shuffle(const SSAVec8s &i0, const SSAVec8s &i1, int index0, int index1, int index2, int index3, int index4, int index5, int index6, int index7); static SSAVec8s extendhi(SSAVec16ub a); static SSAVec8s extendlo(SSAVec16ub a); - //static SSAVec8s min_sse2(SSAVec8s a, SSAVec8s b); - //static SSAVec8s max_sse2(SSAVec8s a, SSAVec8s b); static SSAVec8s mulhi(SSAVec8s a, SSAVec8s b); static SSAVec8s from_llvm(llvm::Value *v) { return SSAVec8s(v); } static llvm::Type *llvm_type();