From 6ccc2d579e7e9f2bce353391aa487f218b3dc5c1 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Wed, 3 Oct 2007 21:01:14 +0000 Subject: [PATCH] Clarify that shifts that are too large are undefined. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@42588 91177308-0d34-0410-b5e6-96231b3b80d8 --- docs/LangRef.html | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/docs/LangRef.html b/docs/LangRef.html index 308dd207e5d..10fb2e6a6c7 100644 --- a/docs/LangRef.html +++ b/docs/LangRef.html @@ -2168,18 +2168,28 @@ Instruction
Syntax:
  <result> = shl <ty> <var1>, <var2>   ; yields {ty}:result
 
+
Overview:
+

The 'shl' instruction returns the first operand shifted to the left a specified number of bits.

+
Arguments:
+

Both arguments to the 'shl' instruction must be the same integer type.

+
Semantics:
-

The value produced is var1 * 2var2.

+ +

The value produced is var1 * 2var2. If +var2 is (statically or dynamically) equal to or larger than the number +of bits in var1, the result is undefined.

+
Example:
   <result> = shl i32 4, %var   ; yields {i32}: 4 << %var
   <result> = shl i32 4, 2      ; yields {i32}: 16
   <result> = shl i32 1, 10     ; yields {i32}: 1024
+  <result> = shl i32 1, 32     ; undefined
 
@@ -2199,9 +2209,11 @@ operand shifted to the right a specified number of bits with zero fill.

integer type.

Semantics:
+

This instruction always performs a logical shift right operation. The most significant bits of the result will be filled with zero bits after the -shift.

+shift. If var2 is (statically or dynamically) equal to or larger than +the number of bits in var1, the result is undefined.

Example:
@@ -2209,6 +2221,7 @@ shift.

<result> = lshr i32 4, 2 ; yields {i32}:result = 1 <result> = lshr i8 4, 3 ; yields {i8}:result = 0 <result> = lshr i8 -2, 1 ; yields {i8}:result = 0x7FFFFFFF + <result> = lshr i32 1, 32 ; undefined
@@ -2232,7 +2245,9 @@ operand shifted to the right a specified number of bits with sign extension.

Semantics:

This instruction always performs an arithmetic shift right operation, The most significant bits of the result will be filled with the sign bit -of var1.

+of var1. If var2 is (statically or dynamically) equal to or +larger than the number of bits in var1, the result is undefined. +

Example:
@@ -2240,6 +2255,7 @@ of var1.

<result> = ashr i32 4, 2 ; yields {i32}:result = 1 <result> = ashr i8 4, 3 ; yields {i8}:result = 0 <result> = ashr i8 -2, 1 ; yields {i8}:result = -1 + <result> = ashr i32 1, 32 ; undefined