Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit f6d56f1

Browse files
committed
Add intrinsics and missing LLVM AsmParser files for Windows ARM64
llvm::parseIR in llvm-7.0\llvm\lib\IRReader\IRReader.cpp calls parseAssembly which is defined in lib/AsmParser/Parser.cpp, but the latter file is not included in swiftshader_llvm which causes unresovled symbol for linking. This CL added the necessary source files under llvm\AsmParser to swiftshader_llvm. This CL also changed __rdtsc() to use Windows ARM64 intrinsic _ReadStatusReg to get cycle counter as alternative of __rdtsc(). Bug: chromium:893460 Change-Id: I269662f2e4249a3ec5495ecad02bc759139e1d4f Reviewed-on: https://swiftshader-review.googlesource.com/c/23508 Reviewed-by: Nicolas Capens <[email protected]> Reviewed-by: Alexis Hétu <[email protected]> Tested-by: Tom Tan <[email protected]>
1 parent a4afa24 commit f6d56f1

File tree

3 files changed

+14
-2
lines changed

3 files changed

+14
-2
lines changed

src/Common/Timer.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,11 @@ namespace sw
5959
int64_t Timer::ticks()
6060
{
6161
#if defined(_WIN32)
62-
return __rdtsc();
62+
#if defined(_M_ARM64)
63+
return _ReadStatusReg(ARM64_PMCCNTR_EL0);
64+
#else
65+
return __rdtsc();
66+
#endif
6367
#elif defined(__i386__) || defined(__x86_64__)
6468
int64_t tsc;
6569
__asm volatile("rdtsc": "=A" (tsc));

src/OpenGL/libEGL/Display.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ Display::~Display()
105105
#define __x86_64__ 1
106106
#endif
107107

108+
#if defined(__i386__) || defined(__x86_64__)
108109
static void cpuid(int registers[4], int info)
109110
{
110111
#if defined(__i386__) || defined(__x86_64__)
@@ -127,6 +128,7 @@ static bool detectSSE()
127128
cpuid(registers, 1);
128129
return (registers[3] & 0x02000000) != 0;
129130
}
131+
#endif
130132

131133
bool Display::initialize()
132134
{

third_party/llvm-7.0/BUILD.gn

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,9 @@ swiftshader_source_set("swiftshader_llvm") {
196196
"llvm/lib/Analysis/ValueLatticeUtils.cpp",
197197
"llvm/lib/Analysis/ValueTracking.cpp",
198198
"llvm/lib/Analysis/VectorUtils.cpp",
199+
"llvm/lib/AsmParser/LLLexer.cpp",
200+
"llvm/lib/AsmParser/LLParser.cpp",
201+
"llvm/lib/AsmParser/Parser.cpp",
199202
"llvm/lib/BinaryFormat/Dwarf.cpp",
200203
"llvm/lib/BinaryFormat/Magic.cpp",
201204
"llvm/lib/BinaryFormat/Wasm.cpp",
@@ -407,7 +410,10 @@ swiftshader_source_set("swiftshader_llvm") {
407410
}
408411

409412
if (target_cpu != current_cpu &&
410-
(current_cpu == "x86" || current_cpu == "x64")) {
413+
(current_cpu == "x86" || current_cpu == "x64") ||
414+
# Windows ARM64 does cross compilation on Windows x64 host, and requires native
415+
# x86 target.
416+
(is_win && target_cpu == "arm64")) {
411417
deps += [ ":swiftshader_llvm_x86" ]
412418
}
413419
}

0 commit comments

Comments
 (0)