corda/sgx-jvm/avian/unittest/codegen/assembler-test.cpp

85 lines
1.6 KiB
C++
Raw Normal View History

2015-03-13 18:52:59 +00:00
/* Copyright (c) 2008-2015, Avian Contributors
2013-02-15 03:54:20 +00:00
Permission to use, copy, modify, and/or distribute this software
for any purpose with or without fee is hereby granted, provided
that the above copyright notice and this permission notice appear
in all copies.
There is NO WARRANTY for this software. See license.txt for
details. */
#include <stdio.h>
#include "avian/common.h"
#include <avian/heap/heap.h>
#include <avian/system/system.h>
#include "avian/target.h"
2013-02-15 14:35:17 +00:00
#include <avian/codegen/assembler.h>
#include <avian/codegen/architecture.h>
#include <avian/codegen/targets.h>
#include <avian/codegen/lir.h>
2013-02-15 03:54:20 +00:00
#include "test-harness.h"
using namespace avian::codegen;
using namespace vm;
2013-02-15 14:35:17 +00:00
class BasicEnv {
2014-07-11 15:50:18 +00:00
public:
2013-02-15 14:35:17 +00:00
System* s;
Heap* heap;
2013-02-24 06:03:01 +00:00
Architecture* arch;
2013-02-15 14:35:17 +00:00
2014-07-11 15:50:18 +00:00
BasicEnv()
: s(makeSystem()),
heap(makeHeap(s, 32 * 1024)),
arch(makeArchitectureNative(s, true))
2013-02-15 14:35:17 +00:00
{
arch->acquire();
}
2014-07-11 15:50:18 +00:00
~BasicEnv()
{
2013-02-15 14:35:17 +00:00
arch->release();
s->dispose();
}
};
class Asm {
2014-07-11 15:50:18 +00:00
public:
2013-02-15 14:35:17 +00:00
Zone zone;
Assembler* a;
2014-07-11 15:50:18 +00:00
Asm(BasicEnv& env)
2014-05-05 04:02:47 +00:00
: zone(env.heap, 8192), a(env.arch->makeAssembler(env.heap, &zone))
2014-07-11 15:50:18 +00:00
{
}
2013-02-15 14:35:17 +00:00
2014-07-11 15:50:18 +00:00
~Asm()
{
2013-02-15 14:35:17 +00:00
a->dispose();
}
};
2014-07-11 15:50:18 +00:00
TEST(BasicAssembler)
{
2014-01-31 00:34:59 +00:00
BasicEnv env;
Asm a(env);
}
2014-07-11 15:50:18 +00:00
TEST(ArchitecturePlan)
{
2014-01-31 00:34:59 +00:00
BasicEnv env;
2014-07-11 15:50:18 +00:00
for (int op = (int)lir::Call; op < (int)lir::AlignedJump; op++) {
2014-01-31 00:34:59 +00:00
bool thunk;
OperandMask mask;
2014-07-11 15:50:18 +00:00
env.arch->plan(
(lir::UnaryOperation)op, vm::TargetBytesPerWord, mask, &thunk);
2014-01-31 00:34:59 +00:00
assertFalse(thunk);
assertNotEqual(static_cast<uint8_t>(0), mask.typeMask);
2014-12-05 00:44:30 +00:00
assertNotEqual(static_cast<uint64_t>(0), (uint64_t)mask.lowRegisterMask);
2013-02-15 03:54:20 +00:00
}
2014-01-31 00:34:59 +00:00
}