mirror of
https://github.com/HeyPuter/gex.git
synced 2026-11-13 20:12:43 -10:00
C++ was dying on SIGILL at `cmge d0, d0, #0`. The scalar AdvSIMD forms share the `11110` group with scalar floating point and are told apart by bit 30, which the decoder was not looking at, so they all fell through to the FP path and out the bottom as undecoded. They are the vector instructions restricted to lane 0, so rather than a parallel set of opcodes they get a `scalar` flag on VArr: decoding reuses the three-same, two-reg-misc, shift-immediate and pairwise tables, and lifting reuses the vector lowerings with commit_vector masking the result down to one lane instead of to 64 bits. The pairwise forms needed real work in the formatter -- they are spelled `-p` rather than `-v` and read a two-lane source -- and that turned up an existing conflation of fmaxv with fmaxnmv, now separate opcodes. Corpus: 414 undecoded -> 311, mnemonic mismatches 0 across 746k instructions. C++ with STL containers, ostringstream and exceptions now matches QEMU byte for byte, static and dynamic; the dynamic build throws across the libstdc++/libgcc_s boundary, so the guest interpreter is relocating and unwinding real shared objects. Both are in the suite: 32 comparisons, all passing.
38 lines
1.5 KiB
C++
38 lines
1.5 KiB
C++
#include <cstdio>
|
|
#include <string>
|
|
#include <vector>
|
|
#include <map>
|
|
#include <memory>
|
|
#include <algorithm>
|
|
#include <stdexcept>
|
|
#include <sstream>
|
|
struct Node { int v; std::unique_ptr<Node> next; Node(int v):v(v){} };
|
|
static int depth(const Node* n){ return n? 1+depth(n->next.get()) : 0; }
|
|
static void thrower(int n){ if(n==0) throw std::runtime_error("bottom"); thrower(n-1); }
|
|
int main(){
|
|
std::vector<int> v; for(int i=0;i<2000;i++) v.push_back((i*7919)%1000);
|
|
std::sort(v.begin(), v.end());
|
|
printf("sorted %zu first=%d last=%d\n", v.size(), v.front(), v.back());
|
|
|
|
std::map<std::string,int> m;
|
|
for(int i=0;i<200;i++){ std::ostringstream o; o<<"key"<<(i%37); m[o.str()]+=i; }
|
|
printf("map size=%zu key0=%d\n", m.size(), m["key0"]);
|
|
|
|
std::string s;
|
|
for(int i=0;i<50;i++) s += std::to_string(i) + ",";
|
|
printf("string len=%zu tail=%s\n", s.size(), s.c_str()+s.size()-8);
|
|
|
|
auto head = std::make_unique<Node>(0);
|
|
Node* cur = head.get();
|
|
for(int i=1;i<100;i++){ cur->next = std::make_unique<Node>(i); cur = cur->next.get(); }
|
|
printf("list depth=%d\n", depth(head.get()));
|
|
|
|
try { thrower(20); } catch (const std::exception& e) { printf("caught: %s\n", e.what()); }
|
|
try { v.at(99999); } catch (const std::out_of_range&) { printf("caught out_of_range\n"); }
|
|
int nested=0;
|
|
try { try { throw 42; } catch(int x){ nested=x; throw std::logic_error("rethrown"); } }
|
|
catch(const std::logic_error& e){ printf("nested=%d then %s\n", nested, e.what()); }
|
|
printf("done\n");
|
|
return 0;
|
|
}
|