Convert compile-time code to not require SIMD

This commit is contained in:
Matthew Barr
2016-10-06 15:33:24 +11:00
parent e993fe1eb0
commit 2214296b7f
25 changed files with 254 additions and 212 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, Intel Corporation
* Copyright (c) 2015-2016, Intel Corporation
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@@ -36,7 +36,7 @@
#include "ue2common.h"
#include "util/charreach.h"
#include "util/simd_types.h"
#include "util/simd_utils.h"
#include "util/dump_mask.h"
using namespace std;
@@ -53,17 +53,15 @@ namespace ue2 {
* bits 456 is the bit that is set at that offset.
*/
void truffleBuildMasks(const CharReach &cr, m128 *shuf_mask_lo_highclear,
m128 *shuf_mask_lo_highset) {
*shuf_mask_lo_highset = zeroes128();
*shuf_mask_lo_highclear = zeroes128();
u8 *lo_highset = (u8 *)shuf_mask_lo_highset;
u8 *lo_highclear = (u8 *)shuf_mask_lo_highclear;
void truffleBuildMasks(const CharReach &cr, u8 *shuf_mask_lo_highclear,
u8 *shuf_mask_lo_highset) {
memset(shuf_mask_lo_highset, 0, sizeof(m128));
memset(shuf_mask_lo_highclear, 0, sizeof(m128));
for (size_t v = cr.find_first(); v != CharReach::npos;
v = cr.find_next(v)) {
DEBUG_PRINTF("adding 0x%02x to %s\n", (u8)v, (v & 0x80) ? "highset" : "highclear");
u8 *change_mask = (v & 0x80) ? lo_highset : lo_highclear;
u8 *change_mask = (v & 0x80) ? shuf_mask_lo_highset : shuf_mask_lo_highclear;
u8 low_nibble = v & 0xf;
u8 bits_456 = (v & 0x70) >> 4;
change_mask[low_nibble] |= 1 << bits_456;
@@ -73,18 +71,16 @@ void truffleBuildMasks(const CharReach &cr, m128 *shuf_mask_lo_highclear,
/*
* Reconstruct the charclass that the truffle masks represent
*/
CharReach truffle2cr(const m128 highclear, const m128 highset) {
const u8 *lo = (const u8 *)&highclear;
const u8 *hi = (const u8 *)&highset;
CharReach truffle2cr(const u8 *highclear, const u8 *highset) {
CharReach cr;
for (u8 i = 0; i < 16; i++) {
u32 bits_456 = lo[i];
u32 bits_456 = highclear[i];
while (bits_456) {
u32 pos = findAndClearLSB_32(&bits_456);
assert(pos < 8);
cr.set(pos << 4 | i);
}
bits_456 = hi[i];
bits_456 = highset[i];
while (bits_456) {
u32 pos = findAndClearLSB_32(&bits_456);
assert(pos < 8);