ci: add po4a
[xz/debian.git] / debug / testfilegen-arm64.c
blob88cadcaae18986015ac45f75e5d1823edb54f887
1 // SPDX-License-Identifier: 0BSD
3 ///////////////////////////////////////////////////////////////////////////////
4 //
5 /// \file testfilegen-arm64.c
6 /// \brief Generates uncompressed test file for the ARM64 filter
7 //
8 // Author: Lasse Collin
9 //
10 ///////////////////////////////////////////////////////////////////////////////
12 #include <stdbool.h>
13 #include <stdint.h>
14 #include <stdio.h>
17 static uint32_t pc4 = 0;
20 static void
21 put32le(uint32_t v)
23 putchar((v >> 0) & 0xFF);
24 putchar((v >> 8) & 0xFF);
25 putchar((v >> 16) & 0xFF);
26 putchar((v >> 24) & 0xFF);
27 ++pc4;
31 static void
32 putbl(uint32_t imm)
34 imm &= (1U << 26) - 1;
35 imm |= 0x25U << 26;
36 put32le(imm);
40 static void
41 putadrp32(uint32_t imm)
43 imm &= 0x1FFFFFU;
45 // fprintf(stderr, "ADRP 0x%08X\n", imm);
47 uint32_t instr = 0x90000000;
48 instr |= (pc4 * 5 + 11) & 0x1F;
49 instr |= (imm & 3) << 29;
50 instr |= (imm >> 2) << 5;
52 put32le(instr);
56 extern int
57 main(void)
59 putbl(0);
60 putbl(0x03FFFFFF);
61 putbl(0x03FFFFFE);
62 putbl(0x03FFFFFD);
64 putbl(3);
65 putbl(2);
66 putbl(1);
67 putbl(0);
70 putbl(0x02000001);
71 putbl(0x02000000);
72 putbl(0x01FFFFFF);
73 putbl(0x01FFFFFE);
75 putbl(0x01111117);
76 putbl(0x01111116);
77 putbl(0x01111115);
78 putbl(0x01111114);
81 putbl(0x02222227);
82 putbl(0x02222226);
83 putbl(0x02222225);
84 putbl(0x02222224);
86 putbl(0U - pc4);
87 putbl(0U - pc4);
88 putbl(0U - pc4);
89 putbl(0U - pc4);
91 putadrp32(0x00);
92 putadrp32(0x05);
93 putadrp32(0x15);
94 putadrp32(0x25);
96 for (unsigned rep = 0; rep < 2; ++rep) {
97 while ((pc4 << 2) & 4095)
98 put32le(0x55555555U);
100 for (unsigned i = 10; i <= 21; ++i) {
101 const uint32_t neg = (0x1FFF00 >> (21 - i)) & ~255U;
102 const uint32_t plus = 1U << (i - 1);
103 putadrp32(0x000000 | plus);
104 putadrp32(0x000005 | plus);
105 putadrp32(0x0000FE | plus);
106 putadrp32(0x0000FF | plus);
108 putadrp32(0x000000 | neg);
109 putadrp32(0x000005 | neg);
110 putadrp32(0x0000FE | neg);
111 putadrp32(0x0000FF | neg);
115 return 0;