blob: 0b1d1aaa7547010c73d8162e55c32904dd4efb0d [file] [log] [blame]
Matt Wala9a0168a2014-07-23 14:56:10 -07001//===- subzero/crosstest/test_icmp.cpp - Implementation for tests ---------===//
2//
3// The Subzero Code Generator
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9//
10// This aims to test the icmp bitcode instruction across all PNaCl primitive
11// and SIMD integer types.
12//
13//===----------------------------------------------------------------------===//
Jim Stichnoth5bc2b1d2014-05-22 13:38:48 -070014
15#include <stdint.h>
16
17#include "test_icmp.h"
John Porto1d235422015-08-12 12:37:53 -070018#include "xdefs.h"
Jim Stichnoth5bc2b1d2014-05-22 13:38:48 -070019
20#define X(cmp, op) \
21 bool icmp##cmp(uint8_t a, uint8_t b) { return a op b; } \
22 bool icmp##cmp(uint16_t a, uint16_t b) { return a op b; } \
23 bool icmp##cmp(uint32_t a, uint32_t b) { return a op b; } \
John Porto1d235422015-08-12 12:37:53 -070024 bool icmp##cmp(uint64 a, uint64 b) { return a op b; } \
Matt Wala9a0168a2014-07-23 14:56:10 -070025 v4ui32 icmp##cmp(v4ui32 a, v4ui32 b) { return a op b; } \
26 v8ui16 icmp##cmp(v8ui16 a, v8ui16 b) { return a op b; } \
David Sehr5c875422015-10-15 10:38:53 -070027 v16ui8 icmp##cmp(v16ui8 a, v16ui8 b) { return a op b; } \
28 bool icmp_zero##cmp(uint8_t a) { return a op 0; } \
29 bool icmp_zero##cmp(uint16_t a) { return a op 0; } \
30 bool icmp_zero##cmp(uint32_t a) { return a op 0; } \
31 bool icmp_zero##cmp(uint64 a) { return a op 0; }
Jim Stichnoth5bc2b1d2014-05-22 13:38:48 -070032ICMP_U_TABLE
33#undef X
Matt Wala9a0168a2014-07-23 14:56:10 -070034
Jim Stichnoth5bc2b1d2014-05-22 13:38:48 -070035#define X(cmp, op) \
Jim Stichnoth7da431b2014-08-05 11:22:37 -070036 bool icmp##cmp(myint8_t a, myint8_t b) { return a op b; } \
Jim Stichnoth5bc2b1d2014-05-22 13:38:48 -070037 bool icmp##cmp(int16_t a, int16_t b) { return a op b; } \
38 bool icmp##cmp(int32_t a, int32_t b) { return a op b; } \
John Porto1d235422015-08-12 12:37:53 -070039 bool icmp##cmp(int64 a, int64 b) { return a op b; } \
Matt Wala9a0168a2014-07-23 14:56:10 -070040 v4si32 icmp##cmp(v4si32 a, v4si32 b) { return a op b; } \
41 v8si16 icmp##cmp(v8si16 a, v8si16 b) { return a op b; } \
David Sehr5c875422015-10-15 10:38:53 -070042 v16si8 icmp##cmp(v16si8 a, v16si8 b) { return a op b; } \
43 bool icmp_zero##cmp(myint8_t a) { return a op 0; } \
44 bool icmp_zero##cmp(int16_t a) { return a op 0; } \
45 bool icmp_zero##cmp(int32_t a) { return a op 0; } \
46 bool icmp_zero##cmp(int64 a) { return a op 0; }
Jim Stichnoth5bc2b1d2014-05-22 13:38:48 -070047ICMP_S_TABLE
48#undef X