From 6fb3bd6a658940287789198d3207b0da04c0a4e6 Mon Sep 17 00:00:00 2001 From: Nate Begeman Date: Sat, 14 Jan 2006 01:25:24 +0000 Subject: Add bswap intrinsics as documented in the Language Reference git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@25309 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/VMCore/Function.cpp | 5 +++++ lib/VMCore/Verifier.cpp | 30 ++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+) (limited to 'lib/VMCore') diff --git a/lib/VMCore/Function.cpp b/lib/VMCore/Function.cpp index 0cbe14c..3abfef9 100644 --- a/lib/VMCore/Function.cpp +++ b/lib/VMCore/Function.cpp @@ -207,6 +207,11 @@ unsigned Function::getIntrinsicID() const { assert(getName().size() != 5 && "'llvm.' is an invalid intrinsic name!"); switch (getName()[5]) { + case 'b': + if (getName() == "llvm.bswap.i16") return Intrinsic::bswap_i16; + if (getName() == "llvm.bswap.i32") return Intrinsic::bswap_i32; + if (getName() == "llvm.bswap.i64") return Intrinsic::bswap_i64; + break; case 'c': if (getName() == "llvm.ctpop") return Intrinsic::ctpop; if (getName() == "llvm.cttz") return Intrinsic::cttz; diff --git a/lib/VMCore/Verifier.cpp b/lib/VMCore/Verifier.cpp index 9dd7184..f67a497 100644 --- a/lib/VMCore/Verifier.cpp +++ b/lib/VMCore/Verifier.cpp @@ -749,6 +749,36 @@ void Verifier::visitIntrinsicFunctionCall(Intrinsic::ID ID, CallInst &CI) { NumArgs = 0; break; + case Intrinsic::bswap_i16: + Assert1(FT->getNumParams() == 1, + "Illegal # arguments for intrinsic function!", IF); + Assert1(FT->getReturnType() == FT->getParamType(0), + "Return type does not match source type", IF); + Assert1(FT->getReturnType() == Type::UShortTy, + "Return type is not ushort!", IF); + NumArgs = 1; + break; + + case Intrinsic::bswap_i32: + Assert1(FT->getNumParams() == 1, + "Illegal # arguments for intrinsic function!", IF); + Assert1(FT->getReturnType() == FT->getParamType(0), + "Return type does not match source type", IF); + Assert1(FT->getReturnType() == Type::UIntTy, + "Return type is not uint!", IF); + NumArgs = 1; + break; + + case Intrinsic::bswap_i64: + Assert1(FT->getNumParams() == 1, + "Illegal # arguments for intrinsic function!", IF); + Assert1(FT->getReturnType() == FT->getParamType(0), + "Return type does not match source type", IF); + Assert1(FT->getReturnType() == Type::ULongTy, + "Return type is not ulong!", IF); + NumArgs = 1; + break; + case Intrinsic::ctpop: case Intrinsic::ctlz: case Intrinsic::cttz: -- cgit v1.1