forked from OSchip/llvm-project
Test for YMMRegisters.
Summary: This patch contains test for reading YMM Registers. The test basically contains an inferior that loads the ymm registers with a bit pattern and the python test executes register read to check if the bit pattern is correctly written in the registers. This test is repeated twice for each register with a different pattern for better sanity. Reviewers: tberghammer, zturner, clayborg Subscribers: tberghammer, danalbert, srhines Differential Revision: https://reviews.llvm.org/D26242 llvm-svn: 285885
This commit is contained in:
parent
db37e5b5c2
commit
0f80cc84f0
|
@ -0,0 +1,7 @@
|
|||
LEVEL = ../../../make
|
||||
|
||||
C_SOURCES := main.c
|
||||
|
||||
CFLAGS_EXTRAS ?= -g -O1
|
||||
|
||||
include $(LEVEL)/Makefile.rules
|
|
@ -0,0 +1,75 @@
|
|||
"""
|
||||
Test that we correctly read the YMM registers.
|
||||
"""
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
|
||||
import os
|
||||
import time
|
||||
import lldb
|
||||
from lldbsuite.test.decorators import *
|
||||
from lldbsuite.test.lldbtest import *
|
||||
from lldbsuite.test import lldbutil
|
||||
|
||||
|
||||
class TestYMMRegister(TestBase):
|
||||
mydir = TestBase.compute_mydir(__file__)
|
||||
|
||||
@skipIfFreeBSD
|
||||
@skipIfiOSSimulator
|
||||
@skipIfTargetAndroid()
|
||||
@skipIf(archs=no_match(['i386', 'x86_64']))
|
||||
def test(self):
|
||||
self.build()
|
||||
self.setTearDownCleanup()
|
||||
|
||||
exe = os.path.join(os.getcwd(), "a.out")
|
||||
target = self.dbg.CreateTarget(exe)
|
||||
|
||||
self.assertTrue(target, VALID_TARGET)
|
||||
|
||||
byte_pattern1 = 0x80
|
||||
byte_pattern2 = 0xFF
|
||||
|
||||
# Launch the process and stop.
|
||||
self.expect("run", PROCESS_STOPPED, substrs=['stopped'])
|
||||
|
||||
# Check stop reason; Should be either signal SIGTRAP or EXC_BREAKPOINT
|
||||
output = self.res.GetOutput()
|
||||
matched = False
|
||||
substrs = [
|
||||
'stop reason = EXC_BREAKPOINT',
|
||||
'stop reason = signal SIGTRAP']
|
||||
for str1 in substrs:
|
||||
matched = output.find(str1) != -1
|
||||
with recording(self, False) as sbuf:
|
||||
print("%s sub string: %s" % ('Expecting', str1), file=sbuf)
|
||||
print("Matched" if matched else "Not Matched", file=sbuf)
|
||||
if matched:
|
||||
break
|
||||
self.assertTrue(matched, STOPPED_DUE_TO_SIGNAL)
|
||||
|
||||
if self.getArchitecture() == 'x86_64':
|
||||
register_range = 16
|
||||
else:
|
||||
register_range = 8
|
||||
for i in range(register_range):
|
||||
self.runCmd("thread step-inst")
|
||||
|
||||
register_byte = (byte_pattern1 | i)
|
||||
pattern = "ymm" + str(i) + " = " + str('{') + (
|
||||
str(hex(register_byte)) + ' ') * 31 + str(hex(register_byte)) + str('}')
|
||||
|
||||
self.expect(
|
||||
"register read ymm" + str(i),
|
||||
substrs=[pattern])
|
||||
|
||||
register_byte = (byte_pattern2 | i)
|
||||
pattern = "ymm" + str(i) + " = " + str('{') + (
|
||||
str(hex(register_byte)) + ' ') * 31 + str(hex(register_byte)) + str('}')
|
||||
|
||||
self.runCmd("thread step-inst")
|
||||
self.expect(
|
||||
"register read ymm" + str(i),
|
||||
substrs=[pattern])
|
|
@ -0,0 +1,67 @@
|
|||
//===-- main.c ------------------------------------------------*- C -*-===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
void func() {
|
||||
unsigned int ymmvalues[16];
|
||||
unsigned char val;
|
||||
unsigned char i;
|
||||
for (i = 0 ; i < 16 ; i++)
|
||||
{
|
||||
val = (0x80 | i);
|
||||
ymmvalues[i] = (val << 24) | (val << 16) | (val << 8) | val;
|
||||
}
|
||||
|
||||
unsigned int ymmallones = 0xFFFFFFFF;
|
||||
__asm__("int3;"
|
||||
"vbroadcastss %1, %%ymm0;"
|
||||
"vbroadcastss %0, %%ymm0;"
|
||||
"vbroadcastss %2, %%ymm1;"
|
||||
"vbroadcastss %0, %%ymm1;"
|
||||
"vbroadcastss %3, %%ymm2;"
|
||||
"vbroadcastss %0, %%ymm2;"
|
||||
"vbroadcastss %4, %%ymm3;"
|
||||
"vbroadcastss %0, %%ymm3;"
|
||||
"vbroadcastss %5, %%ymm4;"
|
||||
"vbroadcastss %0, %%ymm4;"
|
||||
"vbroadcastss %6, %%ymm5;"
|
||||
"vbroadcastss %0, %%ymm5;"
|
||||
"vbroadcastss %7, %%ymm6;"
|
||||
"vbroadcastss %0, %%ymm6;"
|
||||
"vbroadcastss %8, %%ymm7;"
|
||||
"vbroadcastss %0, %%ymm7;"
|
||||
#if defined(__x86_64__)
|
||||
"vbroadcastss %9, %%ymm8;"
|
||||
"vbroadcastss %0, %%ymm8;"
|
||||
"vbroadcastss %10, %%ymm9;"
|
||||
"vbroadcastss %0, %%ymm9;"
|
||||
"vbroadcastss %11, %%ymm10;"
|
||||
"vbroadcastss %0, %%ymm10;"
|
||||
"vbroadcastss %12, %%ymm11;"
|
||||
"vbroadcastss %0, %%ymm11;"
|
||||
"vbroadcastss %13, %%ymm12;"
|
||||
"vbroadcastss %0, %%ymm12;"
|
||||
"vbroadcastss %14, %%ymm13;"
|
||||
"vbroadcastss %0, %%ymm13;"
|
||||
"vbroadcastss %15, %%ymm14;"
|
||||
"vbroadcastss %0, %%ymm14;"
|
||||
"vbroadcastss %16, %%ymm15;"
|
||||
"vbroadcastss %0, %%ymm15;"
|
||||
#endif
|
||||
::"m"(ymmallones),
|
||||
"m"(ymmvalues[0]), "m"(ymmvalues[1]), "m"(ymmvalues[2]), "m"(ymmvalues[3]),
|
||||
"m"(ymmvalues[4]), "m"(ymmvalues[5]), "m"(ymmvalues[6]), "m"(ymmvalues[7])
|
||||
#if defined(__x86_64__)
|
||||
,
|
||||
"m"(ymmvalues[8]), "m"(ymmvalues[9]), "m"(ymmvalues[10]), "m"(ymmvalues[11]),
|
||||
"m"(ymmvalues[12]), "m"(ymmvalues[13]), "m"(ymmvalues[14]), "m"(ymmvalues[15])
|
||||
#endif
|
||||
);
|
||||
}
|
||||
|
||||
int main(int argc, char const *argv[]) { func(); }
|
Loading…
Reference in New Issue