From d3ddbe6bf16251db145e437e5b085f8f5cf855cc Mon Sep 17 00:00:00 2001 From: Luis <42945842+ldiaz94@users.noreply.github.com> Date: Thu, 22 Oct 2026 07:21:52 +0000 Subject: [PATCH] Report 2026-10.35: ROL and ROR, a word rotated The eleventh thaw, by the owner's word, from PROPOSALS.md's "Inlining a procedure that only returns", whose sauce case asked for a rotation of the language's own, and from rcrypto, whose SHA-256 ran at 32 MB/s with its rotations a procedure and 80 with them written out. ROL(x, n) and ROR(x, n) rotate x, of an unsigned integer type, left and right by n bits modulo its width; of constants they are a constant, and an untyped x, which has no width, is an error (sections 4, 6.1 and 6.8; raz(7)). A predeclared name may be hidden, so it breaks no program. For the owner's review before any code. The compiler follows 2026-10.34 until it has them, so make check's version line fails until then, as at 2026-10.33's report. --- diff --git a/PROPOSALS.md b/PROPOSALS.md index 733e13c..2f628ef 100644 --- a/PROPOSALS.md +++ b/PROPOSALS.md @@ -916,7 +916,11 @@ `Str.be32` of four bytes that only returns, or the loop unrolled where it is. A rotate of the language's own, an operator or a built-in procedure, would serve SHA, the other hashes and checksums without -any inlining, but it is a language change, for a thaw. On 100 MB of +any inlining, but it is a language change, for a thaw. **Taken into +the report (2026-10.35):** the built-ins `ROL(x, n)` and `ROR(x, n)`, +by the owner's word, for review; the compiler is next. rcrypto met the +same (its `RAZ-NOTES.md`): SHA-256 at 32 MB/s with `ror` a procedure, +80 with it written out. On 100 MB of new files `sauce commit` takes 1.2 s against the Pascal sauce's 0.7, and `verify` 0.95 s against 0.48: the hashing. diff --git a/doc/raz.7 b/doc/raz.7 index ea3c782..abd0f3c 100644 --- a/doc/raz.7 +++ b/doc/raz.7 @@ -467,6 +467,11 @@ Set, or add to, .Ar p Ns ^ , returning the value before; atomically. +.It Fn ROL x n , Fn ROR x n +.Ar x , +of an unsigned integer type, rotated left or right by +.Ar n +bits modulo its width. .It Cm FENCE A full memory barrier. .It Fn SYSCALL n x1 ... diff --git a/doc/raz.md b/doc/raz.md index e876a75..f30d792 100644 --- a/doc/raz.md +++ b/doc/raz.md @@ -13,7 +13,7 @@ This report defines the language. It is short on purpose. Whatever it doesn't allow, raz doesn't have. -This is version 2026-10.34 of the report; section 11 says where each +This is version 2026-10.35 of the report; section 11 says where each version's changes are told. 2026-10.11 and 2026-10.12 are a thaw the owner chose, for a language anyone can build again. They break programs written for 2026-10.10 and before: for 2026-10.9, say, the report of compiler @@ -48,6 +48,8 @@ instead (the library volume), which breaks a program that calls them with `ADR`. 2026-10.34 is a tenth: `PTR(s)`, the address a slice starts at, even an empty one (section 6.8); it breaks no program. +2026-10.35 is an eleventh: `ROL(x, n)` and `ROR(x, n)`, a word +rotated (sections 6.1 and 6.8); it breaks no program. The language is frozen, softly, from this version on: it changes only to mend a defect, and its library grows only by what breaks no program @@ -375,7 +377,7 @@ **Constants** are evaluated by the compiler. Their expressions use only literals, other constants, operators, conversions, `SIZE`, the `LEN` -of arrays and strings, and a variant's cases. A constant is an integer, +of arrays and strings, `ROL` and `ROR`, and a variant's cases. A constant is an integer, a real, a `BOOL`, a name of an enumeration, a set, a string, an array, a record, a variant or an `ERROR`. A constant of an integer type wraps as the program would: `U8(250) + 10` is 4. Dividing by zero in a constant is @@ -803,6 +805,17 @@ `U8`, `0C0H shl 1` is `80H`. If `x` is an untyped constant, so is the result, and it doesn't wrap: `1 shl 9` is 512, which doesn't fit a `U8`. +`ROL(x, n)` and `ROR(x, n)` (section 6.8) rotate `x` left and right +by `n` bits modulo its width: the bits shifted out at one end come back +in at the other. For `x: U8` holding `81H`, `ROL(x, 1)` is `03H` and +`ROR(x, 1)` is `0C0H`. `x` is of an unsigned integer type, `U8`, `U16`, +`U32`, `U64` or `UINT`, and the result has its type; `n` may be of any +integer type. An untyped constant has no width, so `ROL(1, 3)` is an +error, and `ROL(U32(1), 3)` is 8. Hashes and ciphers are written with +rotations, which machines do in one instruction, and which two shifts +and an `or` say only at more length: `ROR(x, 7)` is `x shr 7 | x shl +25` for a `U32` `x`. + Relations compare as signed or unsigned according to the type. ### 6.2 Booleans @@ -942,6 +955,7 @@ | `CAS(p, old, new)` | if `p^ = old`, sets `p^ := new` and returns `true`; atomically | | `XCHG(p, x)` | sets `p^ := x` and returns the value before, atomically | | `XADD(p, x)` | adds `x` to `p^` and returns the value before, atomically | +| `ROL(x, n)`, `ROR(x, n)` | `x` rotated left, or right, by `n` bits modulo its width; `x` of an unsigned integer type (section 6.1) | | `ARGC()` | the number of command line arguments, an `INT` | | `ARGV()` | the arguments, a `^^U8` (C strings) | diff --git a/doc/report-history.md b/doc/report-history.md index 400ffa1..1483096 100644 --- a/doc/report-history.md +++ b/doc/report-history.md @@ -221,3 +221,9 @@ `Info` gains `seconds` and `special`, for a program that copies files whole: their times in any year, their set-user-id, set-group-id and sticky bits, and a close that fails (volume 2). It breaks no program. +- **2026-10.35.** A thaw, the eleventh, by the owner's word, asked for + by sauce and rcrypto, whose hashes call a procedure for each + rotation: `ROL(x, n)` and `ROR(x, n)` rotate a word of an unsigned + integer type left and right by `n` bits modulo its width, and of + constants are a constant (sections 4, 6.1 and 6.8). A predeclared + name may be hidden (section 2), so it breaks no program.