Added the llvm.readport and llvm.writeport intrinsics.
authorJohn Criswell <criswell@uiuc.edu>
Thu, 8 Apr 2004 20:27:38 +0000 (20:27 +0000)
committerJohn Criswell <criswell@uiuc.edu>
Thu, 8 Apr 2004 20:27:38 +0000 (20:27 +0000)
The Verifier ensures that their parameters are of integral types and have
the correct sign, but it does not enforce any size restrictions because
such restrictions are platform dependent.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12781 91177308-0d34-0410-b5e6-96231b3b80d8

lib/VMCore/Function.cpp
lib/VMCore/Verifier.cpp

index 7d24916b65003db0a93203a3b28683b35d0a883c..332d598787ee240d9951a57f2b21bf027eb6b3d4 100644 (file)
@@ -227,6 +227,7 @@ unsigned Function::getIntrinsicID() const {
     break;
   case 'r':
     if (getName() == "llvm.returnaddress")  return Intrinsic::returnaddress;
+    if (getName() == "llvm.readport")       return Intrinsic::readport;
     break;
   case 's':
     if (getName() == "llvm.setjmp")     return Intrinsic::setjmp;
@@ -237,6 +238,8 @@ unsigned Function::getIntrinsicID() const {
     if (getName() == "llvm.va_copy")  return Intrinsic::vacopy;
     if (getName() == "llvm.va_end")   return Intrinsic::vaend;
     if (getName() == "llvm.va_start") return Intrinsic::vastart;
+  case 'w':
+    if (getName() == "llvm.writeport") return Intrinsic::writeport;
     break;
   }
   // The "llvm." namespace is reserved!
index 30b37ff6fff0caf5b4d617d8a68053ebc38460e8..73192eb77f3f9668aabb70994c04fd996b29b532 100644 (file)
@@ -606,6 +606,26 @@ void Verifier::visitIntrinsicFunctionCall(Intrinsic::ID ID, CallInst &CI) {
     NumArgs = 1;
     break;
 
+  // Verify that read and write port have integral parameters of the correct
+  // signed-ness.
+  case Intrinsic::writeport:
+    Assert1(FT->getNumParams() == 2,
+            "Illegal # arguments for intrinsic function!", IF);
+    Assert1(FT->getParamType(0)->isUnsigned(),
+            "First argument not unsigned int!", IF);
+    Assert1(FT->getParamType(1)->isIntegral(),
+            "First argument not unsigned int!", IF);
+    NumArgs = 2;
+    break;
+
+  case Intrinsic::readport:
+    Assert1(FT->getNumParams() == 1,
+            "Illegal # arguments for intrinsic function!", IF);
+    Assert1(FT->getParamType(0)->isUnsigned(),
+            "First argument not unsigned int!", IF);
+    NumArgs = 1;
+    break;
+
   case Intrinsic::setjmp:          NumArgs = 1; break;
   case Intrinsic::longjmp:         NumArgs = 2; break;
   case Intrinsic::sigsetjmp:       NumArgs = 2; break;