Changeset View
Changeset View
Standalone View
Standalone View
lib/builtins/sparsetableimpl.h
- This file was added.
/* ===-- sparsetableimpl.h - Implement __getsparse* ------------------------=== | |||||
* | |||||
* Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |||||
* See https://llvm.org/LICENSE.txt for license information. | |||||
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |||||
* | |||||
* ===----------------------------------------------------------------------=== | |||||
* | |||||
* Deliberately NOT #pragma once | |||||
* | |||||
* ===----------------------------------------------------------------------=== | |||||
*/ | |||||
// Index range is limited to (1ULL << 38) - 1 | |||||
uint32_t outer = index / 64; | |||||
uint32_t inner = index % 64; | |||||
#ifndef DEFAULT_UNDEFINED | |||||
if (outer >= map[0].length || (map[outer].bitmap & (1ULL << inner)) == 0) { | |||||
#ifdef DEFAULT_CODE | |||||
return df(); | |||||
#else | |||||
return df; | |||||
#endif /*DEFAULT_CODE*/ | |||||
} | |||||
#endif /*DEFAULT_UNDEFINED*/ | |||||
uint64_t mask = ((uint64_t)(-1)) >> (63 - inner); | |||||
uint32_t popcount = Popcountll(map[outer].bitmap & mask); | |||||
return table[map[outer].running_count + popcount]; |