Skip to content

Instantly share code, notes, and snippets.

@aqjune
aqjune / sli_umull.ml
Created May 16, 2023 01:19
sli_umull.ml
View sli_umull.ml
(* sli v3.2d, v4.2d, #32 *)
(* 1. Check that decode succeeds *)
DECODE_CONV `decode (word 0x6f605483)`;;
(* output: - : thm = |- decode (word 1868584067) = SOME (arm_SLI_VEC Q3 Q4 32 64) *)
(* 2. Check that the symbolic output looks ok *)
let code_6f605483 = define `code_6f605483:byte list = [word 0x83; word 0x54; word 0x60; word 0x6f]`;;
let execth = ARM_MK_EXEC_RULE code_6f605483;;
g `ensures arm
@aqjune
aqjune / decode-test-usra.ml
Created April 29, 2023 02:21
decode-test-usra.ml
View decode-test-usra.ml
(* usra v1.2d, v3.2d, #30 *)
(* 1. Check that decode succeeds *)
DECODE_CONV `decode (word 0x6f621461)`;;
(* output: - : thm = |- decode (word 1868698721) = SOME (arm_USRA_VEC Q1 Q3 30 64 128) *)
(* 2. Check that the symbolic output looks ok *)
let code_6f621461 = define `code_6f621461:byte list = [word 0x61; word 0x14; word 0x62; word 0x6f]`;;
let execth = ARM_MK_EXEC_RULE code_6f621461;;
g `ensures arm
(\s. aligned_bytes_loaded s (word pc) code_6f621461 /\
read PC s = word pc)
@aqjune
aqjune / test.ml
Created April 28, 2023 23:57
test.ml
View test.ml
let test_mc =
define_assert_from_elf "test_mc" "test.o"
[
0x3dc00000; (* arm_LDR Q0 X0 (Immediate_Offset (word 0)) *)
0xa9000c22 (* arm_STP X2 X3 X1 (Immediate_Offset (iword (&0))) *)
];;
let TEST_EXEC = ARM_MK_EXEC_RULE test_mc;;
let STORE_DOES_NOT_TOUCH_LDR_Q = prove(
@aqjune
aqjune / tests.ml
Created April 21, 2023 13:04
PR-NEON8
View tests.ml
(* ============= *)
(* 1. dup: https://developer.arm.com/documentation/ddi0602/2022-06/SIMD-FP-Instructions/DUP--general---Duplicate-general-purpose-register-to-vector- *)
(* dup v2.2d, x4 (0x4e080c82, 0100 1110 0000 1000 0000 1100 1000 0010) *)
(* 1. Check that decode succeeds *)
DECODE_CONV `decode (word 0x4e080c82)`;;
(* output: - : thm = |- decode (word 1309150338) = SOME (arm_DUP Q2 X4) *)
(* 2. Check that the symbolic output looks ok *)
let code_4e080c82 = define `code_4e080c82:byte list = [word 0x82; word 0x0c; word 0x08; word 0x4e]`;;
@aqjune
aqjune / bufferize-fail.mlir
Created November 11, 2021 14:13
bufferize-fail.mlir
View bufferize-fail.mlir
#map0 = affine_map<(d0, d1) -> (d0, d1)>
#map1 = affine_map<(d0) -> (d0)>
#map2 = affine_map<(d0, d1) -> (d0)>
module {
func @encrypt(%arg0: tensor<18x131072xi64>, %arg1: tensor<18x131072xi64>) -> tensor<18x131072xi64> {
%cst = arith.constant dense<[1, 131072]> : tensor<2xi64>
%cst_0 = arith.constant dense<1> : tensor<1xi64>
%cst_1 = arith.constant dense<131072> : tensor<1xi64>
%cst_2 = arith.constant dense<[30, 1]> : tensor<2xi64>
%c18 = arith.constant 18 : index
@aqjune
aqjune / ff_seek_frame_binary.c
Created October 18, 2021 03:20
A function that is in seek-preproc.c
View ff_seek_frame_binary.c
int ff_seek_frame_binary(AVFormatContext *s, int stream_index,
int64_t target_ts, int flags)
{
const AVInputFormat *const avif = s->iformat;
int64_t pos_min=pos_min, pos_max=pos_max, pos, pos_limit;
int64_t ts_min, ts_max, ts;
int index;
int64_t ret;
AVStream *st;
FFStream *sti;
@aqjune
aqjune / gist:0dc142cfeb7417d637a1f3682a87d7dc
Created October 18, 2021 03:20
ff_seek_frame_binary.c
View gist:0dc142cfeb7417d637a1f3682a87d7dc
int ff_seek_frame_binary(AVFormatContext *s, int stream_index,
int64_t target_ts, int flags)
{
const AVInputFormat *const avif = s->iformat;
int64_t pos_min=pos_min, pos_max=pos_max, pos, pos_limit;
int64_t ts_min, ts_max, ts;
int index;
int64_t ret;
AVStream *st;
FFStream *sti;
@aqjune
aqjune / conv2d_to_img2col_opt.mlir
Created June 17, 2021 09:55
conv2d_to_img2col_opt.mlir
View conv2d_to_img2col_opt.mlir
// RUN: iree-opt -split-input-file -iree-codegen-convert-conv-to-img2col %s
#map0 = affine_map<(d0, d1, d2, d3, d4, d5) -> (d0, d1 + d3, d2 + d4, d5)>
#map1 = affine_map<(d0, d1, d2, d3, d4, d5) -> (d0, d1, d2, d3, d4, d5)>
module {
func @conv_16433136(%arg0: tensor<1x16x16x4xf32>, %arg1: tensor<3x3x4x16xf32>, %arg2: tensor<1x14x14x16xf32>) -> tensor<1x14x14x16xf32> {
%0 = linalg.init_tensor [1, 14, 14, 3, 3, 4] : tensor<1x14x14x3x3x4xf32>
%1 = linalg.generic {indexing_maps = [#map0, #map1], iterator_types = ["parallel", "parallel", "parallel", "parallel", "parallel", "parallel"]} ins(%arg0 : tensor<1x16x16x4xf32>) outs(%0 : tensor<1x14x14x3x3x4xf32>) {
^bb0(%arg3: f32, %arg4: f32): // no predecessors
linalg.yield %arg3 : f32
@aqjune
aqjune / tellg.cpp
Created April 27, 2021 05:09
tellg.cpp
View tellg.cpp
#include<iostream>
#include<sstream>
using namespace std;
int main() {
stringstream ss;
ss << "aa\nbb\n";
string str1;
getline(ss, str1);
cout << "str(): " << ss.str() << endl;
@aqjune
aqjune / output.txt
Created February 18, 2021 09:40
select-safe-bool-transforms.ll translation validation
View output.txt
----------------------------------------
define i1 @merge_logical_and_and(i1 %X, i1 %Y) {
%0:
%c = select i1 %X, i1 %Y, i1 0
%res = and i1 %X, %c
ret i1 %res
}
=>
define i1 @merge_logical_and_and(i1 %X, i1 %Y) {