text stringlengths 1 1.05M |
|---|
; A109453: Cumulative sum of initial digits of n.
; Submitted by Jon Maiga
; 1,3,6,10,15,21,28,36,45,46,47,48,49,50,51,52,53,54,55,57,59,61,63,65,67,69,71,73,75,78,81,84,87,90,93,96,99,102,105,109,113,117,121,125,129,133,137,141,145,150,155,160,165,170,175,180,185,190,195,201,207,213
mov $3,$0
mov $4,$0
lpb $3
mov $0,$4
sub $3,1
sub $0,$3
mov $2,1
add $2,$0
lpb $0
mov $0,8
div $2,10
lpe
add $1,$2
lpe
mov $0,$1
add $0,1
|
; int feof(FILE *stream)
INCLUDE "config_private.inc"
SECTION code_clib
SECTION code_stdio
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
IF __CLIB_OPT_MULTITHREAD & $02
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
PUBLIC _feof
EXTERN asm_feof
_feof:
pop af
pop ix
push hl
push af
jp asm_feof
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
ELSE
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
PUBLIC _feof
EXTERN _feof_unlocked
defc _feof = _feof_unlocked
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
ENDIF
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
// Copyright (c) 2019 by Robert Bosch GmbH. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#pragma once
#include <cstdint>
#include <iostream>
#include <limits>
namespace iox
{
///@todo restructure and split into multiple files along with an implementation cpp for non-template code
class RelocatablePointer
{
public:
using offset_t = std::ptrdiff_t;
RelocatablePointer()
{
}
explicit RelocatablePointer(const void* ptr)
: m_offset(computeOffset(ptr))
{
}
RelocatablePointer(const RelocatablePointer& other)
: m_offset(computeOffset(other.computeRawPtr()))
{
}
RelocatablePointer(RelocatablePointer&& other)
: m_offset(computeOffset(other.computeRawPtr()))
{
// could set other to null but there is no advantage
// in moving RelocatablePointers since they are lightweight and in principle other is allowed to
// still be functional (you just cannot rely on it)
}
RelocatablePointer& operator=(const RelocatablePointer& other)
{
if (this != &other)
{
m_offset = computeOffset(other.computeRawPtr());
}
return *this;
}
RelocatablePointer& operator=(const void* rawPtr)
{
m_offset = computeOffset(rawPtr);
return *this;
}
RelocatablePointer& operator=(RelocatablePointer&& other)
{
m_offset = computeOffset(other.computeRawPtr());
return *this;
}
const void* operator*() const
{
return computeRawPtr();
}
operator bool() const
{
return m_offset != NULL_POINTER_OFFSET;
}
bool operator!() const
{
return m_offset == NULL_POINTER_OFFSET;
}
void* get()
{
return computeRawPtr();
}
offset_t getOffset()
{
return m_offset;
}
void print() const
{
std::cout << "&m_offset = " << reinterpret_cast<offset_t>(&m_offset) << std::endl;
std::cout << "m_offset = " << m_offset << std::endl;
std::cout << "raw = " << this->operator*() << std::endl;
}
protected:
offset_t m_offset{NULL_POINTER_OFFSET};
static constexpr offset_t NULL_POINTER_OFFSET = std::numeric_limits<offset_t>::max();
inline offset_t computeOffset(const void* ptr) const
{
//@ todo: find most efficient way to do this and check the valid range (signed/unsigned issues)
// this implies that the absolute difference cannot be larger than 2^63 which is probably true in any shared
// memory we use
// otherwise we would need to use unsigned for differences and use one extra bit from somewhere else to indicate
// the sign
// this suffices if both addresses are not too far apart, e.g. when they point to data in a sufficiently "small"
// shared memory
//(if the shared memory is small, the difference does never underflow)
// todo: better first cast to unsigned, then cast to signed later (extends range where it)
return reinterpret_cast<offset_t>(&m_offset) - reinterpret_cast<offset_t>(ptr);
}
inline void* computeRawPtr() const
{
if (m_offset == NULL_POINTER_OFFSET)
return nullptr;
//@ todo: find most efficient way to do this (see above)
return reinterpret_cast<void*>(reinterpret_cast<offset_t>(&m_offset) - m_offset);
}
};
// typed version so we can use operator->
template <typename T>
class relocatable_ptr : public RelocatablePointer
{
public:
relocatable_ptr()
: RelocatablePointer()
{
}
relocatable_ptr(const T* ptr)
: RelocatablePointer(ptr)
{
}
relocatable_ptr(const RelocatablePointer& other)
{
m_offset = computeOffset(other.computeRawPtr());
}
relocatable_ptr(T* rawPtr)
{
m_offset = computeOffset(rawPtr);
}
relocatable_ptr& operator=(const RelocatablePointer& other)
{
m_offset = computeOffset(other.computeRawPtr());
return *this;
}
T& operator*()
{
return *(static_cast<T*>(computeRawPtr()));
}
T* operator->()
{
return static_cast<T*>(computeRawPtr());
}
const T& operator*() const
{
return *(static_cast<T*>(computeRawPtr()));
}
const T* operator->() const
{
return static_cast<T*>(computeRawPtr());
}
T& operator[](uint64_t index)
{
auto ptr = static_cast<T*>(computeRawPtr());
return *(ptr + index);
}
};
} // namespace iox
|
; FILE *fmemopen(void *buf, size_t size, const char *mode)
SECTION code_clib
SECTION code_stdio
PUBLIC fmemopen_callee
EXTERN asm_fmemopen
fmemopen_callee:
pop hl
pop de
pop bc
ex (sp),hl
jp asm_fmemopen
|
; A007958: Even numbers with at least one odd digit.
; 10,12,14,16,18,30,32,34,36,38,50,52,54,56,58,70,72,74,76,78,90,92,94,96,98,100,102,104,106,108,110,112,114,116,118,120,122,124,126,128,130,132,134,136,138,140,142,144,146,148
mov $1,1
mov $2,6
mov $6,$0
lpb $1
add $2,6
add $6,1
lpb $1
sub $1,1
add $2,2
lpe
add $2,2
lpe
lpb $5,5
add $0,5
trn $6,5
lpb $5,3
mov $6,$2
lpe
lpe
lpb $0
sub $0,1
add $1,2
lpe
mov $0,$1
|
;
; System Call for REX6000
;
; $Id: DbReadField.asm,v 1.4 2017-01-03 00:11:31 aralbrec Exp $
;
; extern INT DbReadField(int, int, ... );
;
; Written by Damjan Marion <dmarion@open.hr>
PUBLIC DbReadField
PUBLIC _DbReadField
.DbReadField
._DbReadField
sub 2 ;except 1st 2 params
ld b,a
ld ix,2
add ix,sp
ld hl,0
push hl ; probably page address
.DbReadField_1
ld l,(ix+0)
ld h,(ix+1)
push hl
inc ix
inc ix
djnz DbReadField_1 ;repush args in REX order
ld hl,0
add hl,sp
push hl
ld hl,0
add hl,sp
ld ($c006),hl ; param 4 - points to pointer to other parameters
ld l,(ix+0)
ld h,(ix+1)
ld ($c004),hl ; param 3
inc ix
inc ix
ld l,(ix+0)
ld h,(ix+1)
ld ($c002),hl ; param 2
ld de,$00de ;DB_FINDRECORD
ld ($c000),de
push af ; save number of args
rst $10
pop af
pop hl
;get parameters from stack
ld b,a
.DbReadField_2
pop ix
djnz DbReadField_2
pop hl
ld hl,($c00e)
ret
|
.global s_prepare_buffers
s_prepare_buffers:
push %r11
push %r12
push %rax
push %rbp
push %rcx
push %rdi
push %rsi
lea addresses_A_ht+0x359a, %rsi
lea addresses_A_ht+0xd0aa, %rdi
nop
nop
nop
xor %rax, %rax
mov $25, %rcx
rep movsl
nop
nop
nop
sub $42449, %r12
lea addresses_WC_ht+0x6f6a, %rsi
nop
nop
add %rax, %rax
mov (%rsi), %rdi
nop
nop
nop
nop
cmp $33829, %rsi
lea addresses_D_ht+0x7c6a, %r11
nop
nop
nop
nop
nop
cmp %rsi, %rsi
mov $0x6162636465666768, %rdi
movq %rdi, %xmm2
movups %xmm2, (%r11)
nop
nop
nop
nop
dec %rax
lea addresses_UC_ht+0x479a, %rsi
lea addresses_UC_ht+0xa4b2, %rdi
nop
add %rbp, %rbp
mov $106, %rcx
rep movsl
nop
nop
inc %rcx
lea addresses_A_ht+0x909a, %rax
nop
nop
cmp $21405, %rsi
mov (%rax), %r12
nop
nop
nop
nop
nop
and %r12, %r12
pop %rsi
pop %rdi
pop %rcx
pop %rbp
pop %rax
pop %r12
pop %r11
ret
.global s_faulty_load
s_faulty_load:
push %r10
push %r11
push %r13
push %r15
push %rdi
push %rdx
push %rsi
// Load
lea addresses_WT+0x1581a, %rdi
nop
nop
nop
nop
nop
and %r15, %r15
mov (%rdi), %r11w
nop
nop
nop
nop
cmp %r10, %r10
// Faulty Load
lea addresses_WC+0xc79a, %r10
nop
cmp $35412, %rdx
mov (%r10), %r11d
lea oracles, %r10
and $0xff, %r11
shlq $12, %r11
mov (%r10,%r11,1), %r11
pop %rsi
pop %rdx
pop %rdi
pop %r15
pop %r13
pop %r11
pop %r10
ret
/*
<gen_faulty_load>
[REF]
{'OP': 'LOAD', 'src': {'type': 'addresses_WC', 'size': 4, 'AVXalign': False, 'NT': False, 'congruent': 0, 'same': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_WT', 'size': 2, 'AVXalign': False, 'NT': False, 'congruent': 7, 'same': False}}
[Faulty Load]
{'OP': 'LOAD', 'src': {'type': 'addresses_WC', 'size': 4, 'AVXalign': False, 'NT': False, 'congruent': 0, 'same': True}}
<gen_prepare_buffer>
{'OP': 'REPM', 'src': {'type': 'addresses_A_ht', 'congruent': 8, 'same': True}, 'dst': {'type': 'addresses_A_ht', 'congruent': 1, 'same': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_WC_ht', 'size': 8, 'AVXalign': False, 'NT': True, 'congruent': 4, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_D_ht', 'size': 16, 'AVXalign': False, 'NT': False, 'congruent': 4, 'same': False}}
{'OP': 'REPM', 'src': {'type': 'addresses_UC_ht', 'congruent': 7, 'same': False}, 'dst': {'type': 'addresses_UC_ht', 'congruent': 2, 'same': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_A_ht', 'size': 8, 'AVXalign': False, 'NT': False, 'congruent': 6, 'same': False}}
{'00': 18079}
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
*/
|
; You may customize this and other start-up templates;
; The location of this template is c:\emu8086\inc\0_com_template.txt
org 100h
MOV AX, 1
MOV BX, 5
MOV CX, 5
ADD BX, CX
ADD AX ,BX
ret
|
BITS 64
;TEST_FILE_META_BEGIN
;TEST_TYPE=TEST_F
;TEST_IGNOREFLAGS=
;TEST_FILE_META_END
; CMOVBE32rr
mov ecx, 0x44
mov edx, 0x88
;TEST_BEGIN_RECORDING
cmovbe ecx, edx
;TEST_END_RECORDING
|
; A058373: a(n) = (1/6)*(2*n - 3)*(n + 2)*(n + 1).
; 0,0,-1,-1,2,10,25,49,84,132,195,275,374,494,637,805,1000,1224,1479,1767,2090,2450,2849,3289,3772,4300,4875,5499,6174,6902,7685,8525,9424,10384,11407,12495,13650,14874,16169,17537,18980,20500,22099,23779,25542,27390,29325,31349,33464,35672,37975,40375,42874,45474,48177,50985,53900,56924,60059,63307,66670,70150,73749,77469,81312,85280,89375,93599,97954,102442,107065,111825,116724,121764,126947,132275,137750,143374,149149,155077,161160,167400,173799,180359,187082,193970,201025,208249,215644,223212,230955,238875,246974,255254,263717,272365,281200,290224,299439,308847
mul $0,2
mov $2,2
sub $2,$0
sub $0,2
bin $0,3
mul $2,2
add $0,$2
div $0,4
|
#include "Core/VolumeBehavior/ScatterFunction/HenyeyGreenstein.h"
#include "Common/assertion.h"
#include "Core/Texture/TConstantTexture.h"
#include "Core/SurfaceHit.h"
#include "Core/Texture/TSampler.h"
#include "Math/TVector3.h"
#include "Math/constant.h"
#include <cmath>
namespace ph
{
HenyeyGreenstein::HenyeyGreenstein(const real g) :
HenyeyGreenstein(std::make_shared<TConstantTexture<real>>(g))
{}
HenyeyGreenstein::HenyeyGreenstein(const std::shared_ptr<TTexture<real>>& g) :
ScatterFunction(),
m_g(g)
{
PH_ASSERT(g);
}
HenyeyGreenstein::~HenyeyGreenstein() = default;
void HenyeyGreenstein::evalPhaseFunc(
const SurfaceHit& X,
const Vector3R& I,
const Vector3R& O,
real* const out_pf) const
{
PH_ASSERT(out_pf);
const TSampler<real> sampler(EQuantity::RAW);
const real g = sampler.sample(*m_g, X);
PH_ASSERT(-1.0_r <= g && g <= 1.0_r);
const real g2 = g * g;
const real cosTheta = I.dot(O);
const real base = 1.0_r + g2 + 2.0_r * g * cosTheta;
*out_pf = PH_RECI_4_PI_REAL * (1.0_r - g2) / (base * std::sqrt(base));
}
}// end namespace ph |
;;
;; BriefLZ - small fast Lempel-Ziv
;;
;; NASM small assembler packer
;;
;; Copyright (c) 2002-2004 by Joergen Ibsen / Jibz
;; All Rights Reserved
;;
;; http://www.ibsensoftware.com/
;;
;; This software is provided 'as-is', without any express
;; or implied warranty. In no event will the authors be
;; held liable for any damages arising from the use of
;; this software.
;;
;; Permission is granted to anyone to use this software
;; for any purpose, including commercial applications,
;; and to alter it and redistribute it freely, subject to
;; the following restrictions:
;;
;; 1. The origin of this software must not be
;; misrepresented; you must not claim that you
;; wrote the original software. If you use this
;; software in a product, an acknowledgment in
;; the product documentation would be appreciated
;; but is not required.
;;
;; 2. Altered source versions must be plainly marked
;; as such, and must not be misrepresented as
;; being the original software.
;;
;; 3. This notice may not be removed or altered from
;; any source distribution.
;;
; blz_pack(const void *source,
; void *destination,
; unsigned int length,
; void *workmem);
; Reva notes:
BLZ_WORKMEM_SIZE equ 1024*1024
FUNCALIGN
FNV:
push ecx
push edx
push ebp
push ebx
mov ecx, 4
mov ebx, esi
call fnvhash.0
pop ebx
pop ebp
pop edx
pop ecx
and eax, (BLZ_WORKMEM_SIZE/4)-1
ret
; workmem is allocated
; ( insize -- maxsize )
PROC blz_maxsize
mov ebx, eax
sar ebx, 3
add eax, ebx
add eax, 64
ret
ENDP blz_maxsize
; ( src srcn dest -- dest destn | 0 0 )
PROC blz_pack
; zero out the lookuptable:
upsh BLZ_WORKMEM_SIZE
call mem_alloc
mov [blz_mem], eax
upsh BLZ_WORKMEM_SIZE
upsh 0
call _fill
; set up pointers to the data:
upop edi ; dest ptr
upop ebx ; src len
; EAX -> src ptr. we'll use ESI, and just save our current ESI
push edi
push esi
mov esi, eax
; ESI->src EDI->dst, EBX->count
; save the initial dest ptr away:
lea eax, [ebx + esi - 4]
mov [blz_limit], eax
mov [blz_bkptr], esi
test ebx, ebx ; length == 0?
jz .jmptodone ;
movsb ; fist byte verbatim
cmp ebx, 1 ; only one byte?
.jmptodone: ;
je near .EODdone ;
mov ebp, 1
mov edx, edi ;
inc edi
inc edi
jmp .nexttag
.no_match:
clc
call putbit ; 0-bit = literal
movsb ; copy literal
.nexttag:
cmp esi, [blz_limit] ; esp + .lim$] ; are we done?
jae .donepacking ;
mov ecx, [blz_mem] ; ; [esp + .wkm$] ; ecx -> lookuptable[]
mov ebx, esi ; ebx = buffer - backptr
xchg esi, [blz_bkptr] ; [esp + .bpt$] ; i.e. distance from backptr to current
sub ebx, esi ; (also stores new backptr)
.update:
call FNV
mov [ecx + eax*4], esi ; lookuptable[hash] = backptr
inc esi ; ++backptr
dec ebx
jnz .update ; when done, si is back to current pos
call FNV
mov ebx, [ecx + eax*4] ; ebx = lookuptable[hash]
test ebx, ebx ; no match?
jz .no_match ;
; check match length
mov ecx, [blz_limit] ;[esp + .lim$] ; ecx = max allowed match length
sub ecx, esi ;
add ecx, 4 ;
push edx
xor eax, eax
.compare:
mov dl, [ebx + eax] ; compare possible match with current
cmp dl, [esi + eax] ;
jne .matchlen_found
inc eax
dec ecx
jnz .compare
.matchlen_found:
pop edx
cmp eax, 4 ; match too short?
jb .no_match ;
mov ecx, esi ;
sub ecx, ebx ; ecx = matchpos
call putbit1 ; 1-bit = match
add esi, eax ; update esi to next position
dec eax
dec eax
call putgamma ; output gamma coding of matchlen - 2
dec ecx ; matchpos > 0, so subtract 1
mov eax, ecx ; eax = (matchpos >> 8) + 2
shr eax, 8 ;
inc eax
inc eax
call putgamma ; output gamma coding of (matchpos >> 8) + 2
xchg eax, ecx ; output low 8 bits of matchpos
stosb ;
jmp .nexttag
.donepacking:
mov eax, [blz_limit] ;[esp + .lim$] ; ebx = source + length
lea ebx, [eax + 4] ;
jmp .check_final_literals
.final_literals:
clc
call putbit ; 0-bit = literal
movsb ; copy literal
.check_final_literals:
cmp esi, ebx
jb .final_literals
test ebp, ebp ; do we need to fix the last tag?
jz .EODdone ;
.doEOD:
add bp, bp ; shift last tag into position
jnc .doEOD ;
mov [edx], bp ; and put it into it's place
.EODdone:
pop esi
pop eax ; original ptr
dup
sub eax, edi ; blz_limit[esp + .dst$] ;
neg eax
upsh [blz_mem]
call mem_free
ret
; =============================================================
putbit1: ; add 1-bit
stc
putbit: ; add bit according to carry
dec ebp
jns .bitsleft
mov edx, edi
inc edi
inc ebp
inc edi
.bitsleft:
inc ebp
adc bp, bp ; is this reall correct?
jnc .done
mov [edx], bp
xor ebp, ebp
.done:
ret
putgamma: ; output gamma coding of value in eax
push ebx ; (eax > 1)
push eax
shr eax, 1
xor ebx, ebx
inc ebx
.revmore:
shr eax, 1
jz .outstart
adc ebx, ebx
jmp .revmore
.outmore:
call putbit
call putbit1
.outstart:
shr ebx, 1
jnz .outmore
pop eax
shr eax, 1
call putbit
call putbit ; CF = 0 from call above
pop ebx
ret
ENDP blz_pack
; unpack
; =============================================================
; blz_depack(const void *source,
; void *destination,
; unsigned int depacked_length);
; ( src srcn dest -- dest' destn' | 0 0 )
PROC blz_depack
upop edi ; dest
push edi
upop ebx ; length
; eax is src
push esi
mov esi, eax
xor edx, edx ; initialise tag
add ebx, edi ; ebx = destination + length
.literal:
movsb ; copy literal
.nexttag:
cmp edi, ebx ; are we done?
jae .donedepacking
call .getbit ; literal or match?
jnc .literal ;
call .getgamma ; ecx = matchlen
xchg eax, ecx ;
call .getgamma ; eax = (matchpos >> 8) + 2
dec eax ; eax = (matchpos >> 8)
dec eax ;
inc ecx ; matchlen >= 4, so add 2
inc ecx ;
shl eax, 8 ; eax = high part of matchpos
mov al, [esi]
inc esi
inc eax ; matchpos > 0, so add 1
push esi
mov esi, edi ; copy match
sub esi, eax ;
rep movsb ;
pop esi
jmp .nexttag
.getbit: ; get next tag-bit into carry
add dx, dx
jnz .stillbitsleft
xchg eax, edx
mov ax, [esi]
inc esi
inc esi
xchg eax, edx
add dx, dx
inc edx
.stillbitsleft:
ret
.getgamma: ; gamma decode value into eax
mov eax, 1
.getmore:
call .getbit
adc eax, eax
call .getbit
jc .getmore
ret
.donedepacking:
pop esi
pop eax ; old edi
dup
sub eax, edi
neg eax
ret
ENDP blz_depack
|
;
; jdclrss2-64.asm - colorspace conversion (64-bit SSE2)
;
; Copyright 2009, 2012 Pierre Ossman <ossman@cendio.se> for Cendio AB
; Copyright 2009, 2012 D. R. Commander
;
; Based on
; x86 SIMD extension for IJG JPEG library
; Copyright (C) 1999-2006, MIYASAKA Masaru.
; For conditions of distribution and use, see copyright notice in jsimdext.inc
;
; This file should be assembled with NASM (Netwide Assembler),
; can *not* be assembled with Microsoft's MASM or any compatible
; assembler (including Borland's Turbo Assembler).
; NASM is available from http://nasm.sourceforge.net/ or
; http://sourceforge.net/project/showfiles.php?group_id=6208
;
; [TAB8]
%include "jcolsamp.inc"
; --------------------------------------------------------------------------
;
; Convert some rows of samples to the output colorspace.
;
; GLOBAL(void)
; jsimd_ycc_rgb_convert_sse2 (JDIMENSION out_width,
; JSAMPIMAGE input_buf, JDIMENSION input_row,
; JSAMPARRAY output_buf, int num_rows)
;
; r10 = JDIMENSION out_width
; r11 = JSAMPIMAGE input_buf
; r12 = JDIMENSION input_row
; r13 = JSAMPARRAY output_buf
; r14 = int num_rows
%define wk(i) rbp-(WK_NUM-(i))*SIZEOF_XMMWORD ; xmmword wk[WK_NUM]
%define WK_NUM 2
align 16
global EXTN(jsimd_ycc_rgb_convert_sse2)
EXTN(jsimd_ycc_rgb_convert_sse2):
push rbp
mov rax,rsp ; rax = original rbp
sub rsp, byte 4
and rsp, byte (-SIZEOF_XMMWORD) ; align to 128 bits
mov [rsp],rax
mov rbp,rsp ; rbp = aligned rbp
lea rsp, [wk(0)]
collect_args
push rbx
mov rcx, r10 ; num_cols
test rcx,rcx
jz near .return
push rcx
mov rdi, r11
mov rcx, r12
mov rsi, JSAMPARRAY [rdi+0*SIZEOF_JSAMPARRAY]
mov rbx, JSAMPARRAY [rdi+1*SIZEOF_JSAMPARRAY]
mov rdx, JSAMPARRAY [rdi+2*SIZEOF_JSAMPARRAY]
lea rsi, [rsi+rcx*SIZEOF_JSAMPROW]
lea rbx, [rbx+rcx*SIZEOF_JSAMPROW]
lea rdx, [rdx+rcx*SIZEOF_JSAMPROW]
pop rcx
mov rdi, r13
mov eax, r14d
test rax,rax
jle near .return
.rowloop:
push rax
push rdi
push rdx
push rbx
push rsi
push rcx ; col
mov rsi, JSAMPROW [rsi] ; inptr0
mov rbx, JSAMPROW [rbx] ; inptr1
mov rdx, JSAMPROW [rdx] ; inptr2
mov rdi, JSAMPROW [rdi] ; outptr
.columnloop:
movdqa xmm5, XMMWORD [rbx] ; xmm5=Cb(0123456789ABCDEF)
movdqa xmm1, XMMWORD [rdx] ; xmm1=Cr(0123456789ABCDEF)
pcmpeqw xmm4,xmm4
pcmpeqw xmm7,xmm7
psrlw xmm4,BYTE_BIT
psllw xmm7,7 ; xmm7={0xFF80 0xFF80 0xFF80 0xFF80 ..}
movdqa xmm0,xmm4 ; xmm0=xmm4={0xFF 0x00 0xFF 0x00 ..}
pand xmm4,xmm5 ; xmm4=Cb(02468ACE)=CbE
psrlw xmm5,BYTE_BIT ; xmm5=Cb(13579BDF)=CbO
pand xmm0,xmm1 ; xmm0=Cr(02468ACE)=CrE
psrlw xmm1,BYTE_BIT ; xmm1=Cr(13579BDF)=CrO
paddw xmm4,xmm7
paddw xmm5,xmm7
paddw xmm0,xmm7
paddw xmm1,xmm7
; (Original)
; R = Y + 1.40200 * Cr
; G = Y - 0.34414 * Cb - 0.71414 * Cr
; B = Y + 1.77200 * Cb
;
; (This implementation)
; R = Y + 0.40200 * Cr + Cr
; G = Y - 0.34414 * Cb + 0.28586 * Cr - Cr
; B = Y - 0.22800 * Cb + Cb + Cb
movdqa xmm2,xmm4 ; xmm2=CbE
movdqa xmm3,xmm5 ; xmm3=CbO
paddw xmm4,xmm4 ; xmm4=2*CbE
paddw xmm5,xmm5 ; xmm5=2*CbO
movdqa xmm6,xmm0 ; xmm6=CrE
movdqa xmm7,xmm1 ; xmm7=CrO
paddw xmm0,xmm0 ; xmm0=2*CrE
paddw xmm1,xmm1 ; xmm1=2*CrO
pmulhw xmm4,[rel PW_MF0228] ; xmm4=(2*CbE * -FIX(0.22800))
pmulhw xmm5,[rel PW_MF0228] ; xmm5=(2*CbO * -FIX(0.22800))
pmulhw xmm0,[rel PW_F0402] ; xmm0=(2*CrE * FIX(0.40200))
pmulhw xmm1,[rel PW_F0402] ; xmm1=(2*CrO * FIX(0.40200))
paddw xmm4,[rel PW_ONE]
paddw xmm5,[rel PW_ONE]
psraw xmm4,1 ; xmm4=(CbE * -FIX(0.22800))
psraw xmm5,1 ; xmm5=(CbO * -FIX(0.22800))
paddw xmm0,[rel PW_ONE]
paddw xmm1,[rel PW_ONE]
psraw xmm0,1 ; xmm0=(CrE * FIX(0.40200))
psraw xmm1,1 ; xmm1=(CrO * FIX(0.40200))
paddw xmm4,xmm2
paddw xmm5,xmm3
paddw xmm4,xmm2 ; xmm4=(CbE * FIX(1.77200))=(B-Y)E
paddw xmm5,xmm3 ; xmm5=(CbO * FIX(1.77200))=(B-Y)O
paddw xmm0,xmm6 ; xmm0=(CrE * FIX(1.40200))=(R-Y)E
paddw xmm1,xmm7 ; xmm1=(CrO * FIX(1.40200))=(R-Y)O
movdqa XMMWORD [wk(0)], xmm4 ; wk(0)=(B-Y)E
movdqa XMMWORD [wk(1)], xmm5 ; wk(1)=(B-Y)O
movdqa xmm4,xmm2
movdqa xmm5,xmm3
punpcklwd xmm2,xmm6
punpckhwd xmm4,xmm6
pmaddwd xmm2,[rel PW_MF0344_F0285]
pmaddwd xmm4,[rel PW_MF0344_F0285]
punpcklwd xmm3,xmm7
punpckhwd xmm5,xmm7
pmaddwd xmm3,[rel PW_MF0344_F0285]
pmaddwd xmm5,[rel PW_MF0344_F0285]
paddd xmm2,[rel PD_ONEHALF]
paddd xmm4,[rel PD_ONEHALF]
psrad xmm2,SCALEBITS
psrad xmm4,SCALEBITS
paddd xmm3,[rel PD_ONEHALF]
paddd xmm5,[rel PD_ONEHALF]
psrad xmm3,SCALEBITS
psrad xmm5,SCALEBITS
packssdw xmm2,xmm4 ; xmm2=CbE*-FIX(0.344)+CrE*FIX(0.285)
packssdw xmm3,xmm5 ; xmm3=CbO*-FIX(0.344)+CrO*FIX(0.285)
psubw xmm2,xmm6 ; xmm2=CbE*-FIX(0.344)+CrE*-FIX(0.714)=(G-Y)E
psubw xmm3,xmm7 ; xmm3=CbO*-FIX(0.344)+CrO*-FIX(0.714)=(G-Y)O
movdqa xmm5, XMMWORD [rsi] ; xmm5=Y(0123456789ABCDEF)
pcmpeqw xmm4,xmm4
psrlw xmm4,BYTE_BIT ; xmm4={0xFF 0x00 0xFF 0x00 ..}
pand xmm4,xmm5 ; xmm4=Y(02468ACE)=YE
psrlw xmm5,BYTE_BIT ; xmm5=Y(13579BDF)=YO
paddw xmm0,xmm4 ; xmm0=((R-Y)E+YE)=RE=R(02468ACE)
paddw xmm1,xmm5 ; xmm1=((R-Y)O+YO)=RO=R(13579BDF)
packuswb xmm0,xmm0 ; xmm0=R(02468ACE********)
packuswb xmm1,xmm1 ; xmm1=R(13579BDF********)
paddw xmm2,xmm4 ; xmm2=((G-Y)E+YE)=GE=G(02468ACE)
paddw xmm3,xmm5 ; xmm3=((G-Y)O+YO)=GO=G(13579BDF)
packuswb xmm2,xmm2 ; xmm2=G(02468ACE********)
packuswb xmm3,xmm3 ; xmm3=G(13579BDF********)
paddw xmm4, XMMWORD [wk(0)] ; xmm4=(YE+(B-Y)E)=BE=B(02468ACE)
paddw xmm5, XMMWORD [wk(1)] ; xmm5=(YO+(B-Y)O)=BO=B(13579BDF)
packuswb xmm4,xmm4 ; xmm4=B(02468ACE********)
packuswb xmm5,xmm5 ; xmm5=B(13579BDF********)
%if RGB_PIXELSIZE == 3 ; ---------------
; xmmA=(00 02 04 06 08 0A 0C 0E **), xmmB=(01 03 05 07 09 0B 0D 0F **)
; xmmC=(10 12 14 16 18 1A 1C 1E **), xmmD=(11 13 15 17 19 1B 1D 1F **)
; xmmE=(20 22 24 26 28 2A 2C 2E **), xmmF=(21 23 25 27 29 2B 2D 2F **)
; xmmG=(** ** ** ** ** ** ** ** **), xmmH=(** ** ** ** ** ** ** ** **)
punpcklbw xmmA,xmmC ; xmmA=(00 10 02 12 04 14 06 16 08 18 0A 1A 0C 1C 0E 1E)
punpcklbw xmmE,xmmB ; xmmE=(20 01 22 03 24 05 26 07 28 09 2A 0B 2C 0D 2E 0F)
punpcklbw xmmD,xmmF ; xmmD=(11 21 13 23 15 25 17 27 19 29 1B 2B 1D 2D 1F 2F)
movdqa xmmG,xmmA
movdqa xmmH,xmmA
punpcklwd xmmA,xmmE ; xmmA=(00 10 20 01 02 12 22 03 04 14 24 05 06 16 26 07)
punpckhwd xmmG,xmmE ; xmmG=(08 18 28 09 0A 1A 2A 0B 0C 1C 2C 0D 0E 1E 2E 0F)
psrldq xmmH,2 ; xmmH=(02 12 04 14 06 16 08 18 0A 1A 0C 1C 0E 1E -- --)
psrldq xmmE,2 ; xmmE=(22 03 24 05 26 07 28 09 2A 0B 2C 0D 2E 0F -- --)
movdqa xmmC,xmmD
movdqa xmmB,xmmD
punpcklwd xmmD,xmmH ; xmmD=(11 21 02 12 13 23 04 14 15 25 06 16 17 27 08 18)
punpckhwd xmmC,xmmH ; xmmC=(19 29 0A 1A 1B 2B 0C 1C 1D 2D 0E 1E 1F 2F -- --)
psrldq xmmB,2 ; xmmB=(13 23 15 25 17 27 19 29 1B 2B 1D 2D 1F 2F -- --)
movdqa xmmF,xmmE
punpcklwd xmmE,xmmB ; xmmE=(22 03 13 23 24 05 15 25 26 07 17 27 28 09 19 29)
punpckhwd xmmF,xmmB ; xmmF=(2A 0B 1B 2B 2C 0D 1D 2D 2E 0F 1F 2F -- -- -- --)
pshufd xmmH,xmmA,0x4E; xmmH=(04 14 24 05 06 16 26 07 00 10 20 01 02 12 22 03)
movdqa xmmB,xmmE
punpckldq xmmA,xmmD ; xmmA=(00 10 20 01 11 21 02 12 02 12 22 03 13 23 04 14)
punpckldq xmmE,xmmH ; xmmE=(22 03 13 23 04 14 24 05 24 05 15 25 06 16 26 07)
punpckhdq xmmD,xmmB ; xmmD=(15 25 06 16 26 07 17 27 17 27 08 18 28 09 19 29)
pshufd xmmH,xmmG,0x4E; xmmH=(0C 1C 2C 0D 0E 1E 2E 0F 08 18 28 09 0A 1A 2A 0B)
movdqa xmmB,xmmF
punpckldq xmmG,xmmC ; xmmG=(08 18 28 09 19 29 0A 1A 0A 1A 2A 0B 1B 2B 0C 1C)
punpckldq xmmF,xmmH ; xmmF=(2A 0B 1B 2B 0C 1C 2C 0D 2C 0D 1D 2D 0E 1E 2E 0F)
punpckhdq xmmC,xmmB ; xmmC=(1D 2D 0E 1E 2E 0F 1F 2F 1F 2F -- -- -- -- -- --)
punpcklqdq xmmA,xmmE ; xmmA=(00 10 20 01 11 21 02 12 22 03 13 23 04 14 24 05)
punpcklqdq xmmD,xmmG ; xmmD=(15 25 06 16 26 07 17 27 08 18 28 09 19 29 0A 1A)
punpcklqdq xmmF,xmmC ; xmmF=(2A 0B 1B 2B 0C 1C 2C 0D 1D 2D 0E 1E 2E 0F 1F 2F)
cmp rcx, byte SIZEOF_XMMWORD
jb short .column_st32
test rdi, SIZEOF_XMMWORD-1
jnz short .out1
; --(aligned)-------------------
movntdq XMMWORD [rdi+0*SIZEOF_XMMWORD], xmmA
movntdq XMMWORD [rdi+1*SIZEOF_XMMWORD], xmmD
movntdq XMMWORD [rdi+2*SIZEOF_XMMWORD], xmmF
jmp short .out0
.out1: ; --(unaligned)-----------------
movdqu XMMWORD [rdi+0*SIZEOF_XMMWORD], xmmA
movdqu XMMWORD [rdi+1*SIZEOF_XMMWORD], xmmD
movdqu XMMWORD [rdi+2*SIZEOF_XMMWORD], xmmF
.out0:
add rdi, byte RGB_PIXELSIZE*SIZEOF_XMMWORD ; outptr
sub rcx, byte SIZEOF_XMMWORD
jz near .nextrow
add rsi, byte SIZEOF_XMMWORD ; inptr0
add rbx, byte SIZEOF_XMMWORD ; inptr1
add rdx, byte SIZEOF_XMMWORD ; inptr2
jmp near .columnloop
.column_st32:
lea rcx, [rcx+rcx*2] ; imul ecx, RGB_PIXELSIZE
cmp rcx, byte 2*SIZEOF_XMMWORD
jb short .column_st16
movdqu XMMWORD [rdi+0*SIZEOF_XMMWORD], xmmA
movdqu XMMWORD [rdi+1*SIZEOF_XMMWORD], xmmD
add rdi, byte 2*SIZEOF_XMMWORD ; outptr
movdqa xmmA,xmmF
sub rcx, byte 2*SIZEOF_XMMWORD
jmp short .column_st15
.column_st16:
cmp rcx, byte SIZEOF_XMMWORD
jb short .column_st15
movdqu XMMWORD [rdi+0*SIZEOF_XMMWORD], xmmA
add rdi, byte SIZEOF_XMMWORD ; outptr
movdqa xmmA,xmmD
sub rcx, byte SIZEOF_XMMWORD
.column_st15:
; Store the lower 8 bytes of xmmA to the output when it has enough
; space.
cmp rcx, byte SIZEOF_MMWORD
jb short .column_st7
movq XMM_MMWORD [rdi], xmmA
add rdi, byte SIZEOF_MMWORD
sub rcx, byte SIZEOF_MMWORD
psrldq xmmA, SIZEOF_MMWORD
.column_st7:
; Store the lower 4 bytes of xmmA to the output when it has enough
; space.
cmp rcx, byte SIZEOF_DWORD
jb short .column_st3
movd XMM_DWORD [rdi], xmmA
add rdi, byte SIZEOF_DWORD
sub rcx, byte SIZEOF_DWORD
psrldq xmmA, SIZEOF_DWORD
.column_st3:
; Store the lower 2 bytes of rax to the output when it has enough
; space.
movd eax, xmmA
cmp rcx, byte SIZEOF_WORD
jb short .column_st1
mov WORD [rdi], ax
add rdi, byte SIZEOF_WORD
sub rcx, byte SIZEOF_WORD
shr rax, 16
.column_st1:
; Store the lower 1 byte of rax to the output when it has enough
; space.
test rcx, rcx
jz short .nextrow
mov BYTE [rdi], al
%else ; RGB_PIXELSIZE == 4 ; -----------
%ifdef RGBX_FILLER_0XFF
pcmpeqb xmm6,xmm6 ; xmm6=XE=X(02468ACE********)
pcmpeqb xmm7,xmm7 ; xmm7=XO=X(13579BDF********)
%else
pxor xmm6,xmm6 ; xmm6=XE=X(02468ACE********)
pxor xmm7,xmm7 ; xmm7=XO=X(13579BDF********)
%endif
; xmmA=(00 02 04 06 08 0A 0C 0E **), xmmB=(01 03 05 07 09 0B 0D 0F **)
; xmmC=(10 12 14 16 18 1A 1C 1E **), xmmD=(11 13 15 17 19 1B 1D 1F **)
; xmmE=(20 22 24 26 28 2A 2C 2E **), xmmF=(21 23 25 27 29 2B 2D 2F **)
; xmmG=(30 32 34 36 38 3A 3C 3E **), xmmH=(31 33 35 37 39 3B 3D 3F **)
punpcklbw xmmA,xmmC ; xmmA=(00 10 02 12 04 14 06 16 08 18 0A 1A 0C 1C 0E 1E)
punpcklbw xmmE,xmmG ; xmmE=(20 30 22 32 24 34 26 36 28 38 2A 3A 2C 3C 2E 3E)
punpcklbw xmmB,xmmD ; xmmB=(01 11 03 13 05 15 07 17 09 19 0B 1B 0D 1D 0F 1F)
punpcklbw xmmF,xmmH ; xmmF=(21 31 23 33 25 35 27 37 29 39 2B 3B 2D 3D 2F 3F)
movdqa xmmC,xmmA
punpcklwd xmmA,xmmE ; xmmA=(00 10 20 30 02 12 22 32 04 14 24 34 06 16 26 36)
punpckhwd xmmC,xmmE ; xmmC=(08 18 28 38 0A 1A 2A 3A 0C 1C 2C 3C 0E 1E 2E 3E)
movdqa xmmG,xmmB
punpcklwd xmmB,xmmF ; xmmB=(01 11 21 31 03 13 23 33 05 15 25 35 07 17 27 37)
punpckhwd xmmG,xmmF ; xmmG=(09 19 29 39 0B 1B 2B 3B 0D 1D 2D 3D 0F 1F 2F 3F)
movdqa xmmD,xmmA
punpckldq xmmA,xmmB ; xmmA=(00 10 20 30 01 11 21 31 02 12 22 32 03 13 23 33)
punpckhdq xmmD,xmmB ; xmmD=(04 14 24 34 05 15 25 35 06 16 26 36 07 17 27 37)
movdqa xmmH,xmmC
punpckldq xmmC,xmmG ; xmmC=(08 18 28 38 09 19 29 39 0A 1A 2A 3A 0B 1B 2B 3B)
punpckhdq xmmH,xmmG ; xmmH=(0C 1C 2C 3C 0D 1D 2D 3D 0E 1E 2E 3E 0F 1F 2F 3F)
cmp rcx, byte SIZEOF_XMMWORD
jb short .column_st32
test rdi, SIZEOF_XMMWORD-1
jnz short .out1
; --(aligned)-------------------
movntdq XMMWORD [rdi+0*SIZEOF_XMMWORD], xmmA
movntdq XMMWORD [rdi+1*SIZEOF_XMMWORD], xmmD
movntdq XMMWORD [rdi+2*SIZEOF_XMMWORD], xmmC
movntdq XMMWORD [rdi+3*SIZEOF_XMMWORD], xmmH
jmp short .out0
.out1: ; --(unaligned)-----------------
movdqu XMMWORD [rdi+0*SIZEOF_XMMWORD], xmmA
movdqu XMMWORD [rdi+1*SIZEOF_XMMWORD], xmmD
movdqu XMMWORD [rdi+2*SIZEOF_XMMWORD], xmmC
movdqu XMMWORD [rdi+3*SIZEOF_XMMWORD], xmmH
.out0:
add rdi, byte RGB_PIXELSIZE*SIZEOF_XMMWORD ; outptr
sub rcx, byte SIZEOF_XMMWORD
jz near .nextrow
add rsi, byte SIZEOF_XMMWORD ; inptr0
add rbx, byte SIZEOF_XMMWORD ; inptr1
add rdx, byte SIZEOF_XMMWORD ; inptr2
jmp near .columnloop
.column_st32:
cmp rcx, byte SIZEOF_XMMWORD/2
jb short .column_st16
movdqu XMMWORD [rdi+0*SIZEOF_XMMWORD], xmmA
movdqu XMMWORD [rdi+1*SIZEOF_XMMWORD], xmmD
add rdi, byte 2*SIZEOF_XMMWORD ; outptr
movdqa xmmA,xmmC
movdqa xmmD,xmmH
sub rcx, byte SIZEOF_XMMWORD/2
.column_st16:
cmp rcx, byte SIZEOF_XMMWORD/4
jb short .column_st15
movdqu XMMWORD [rdi+0*SIZEOF_XMMWORD], xmmA
add rdi, byte SIZEOF_XMMWORD ; outptr
movdqa xmmA,xmmD
sub rcx, byte SIZEOF_XMMWORD/4
.column_st15:
; Store two pixels (8 bytes) of xmmA to the output when it has enough
; space.
cmp rcx, byte SIZEOF_XMMWORD/8
jb short .column_st7
movq MMWORD [rdi], xmmA
add rdi, byte SIZEOF_XMMWORD/8*4
sub rcx, byte SIZEOF_XMMWORD/8
psrldq xmmA, SIZEOF_XMMWORD/8*4
.column_st7:
; Store one pixel (4 bytes) of xmmA to the output when it has enough
; space.
test rcx, rcx
jz short .nextrow
movd XMM_DWORD [rdi], xmmA
%endif ; RGB_PIXELSIZE ; ---------------
.nextrow:
pop rcx
pop rsi
pop rbx
pop rdx
pop rdi
pop rax
add rsi, byte SIZEOF_JSAMPROW
add rbx, byte SIZEOF_JSAMPROW
add rdx, byte SIZEOF_JSAMPROW
add rdi, byte SIZEOF_JSAMPROW ; output_buf
dec rax ; num_rows
jg near .rowloop
sfence ; flush the write buffer
.return:
pop rbx
uncollect_args
mov rsp,rbp ; rsp <- aligned rbp
pop rsp ; rsp <- original rbp
pop rbp
ret
; For some reason, the OS X linker does not honor the request to align the
; segment unless we do this.
align 16
|
; Test case:
xor a
IRP ?value, 1 , 2, 4, 8
or ?value
ENDM
ld (value),a
end:
jp end
value:
db 0
|
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++98, c++03
// <experimental/filesystem>
// bool is_empty(path const& p);
// bool is_empty(path const& p, std::error_code& ec);
#include "filesystem_include.hpp"
#include <type_traits>
#include <cassert>
#include "test_macros.h"
#include "rapid-cxx-test.hpp"
#include "filesystem_test_helper.hpp"
using namespace fs;
TEST_SUITE(is_empty_test_suite)
TEST_CASE(signature_test)
{
const path p; ((void)p);
std::error_code ec; ((void)ec);
ASSERT_NOT_NOEXCEPT(is_empty(p, ec));
ASSERT_NOT_NOEXCEPT(is_empty(p));
}
TEST_CASE(test_exist_not_found)
{
const path p = StaticEnv::DNE;
std::error_code ec;
TEST_CHECK(is_empty(p, ec) == false);
TEST_CHECK(ec);
TEST_CHECK_THROW(filesystem_error, is_empty(p));
}
TEST_CASE(test_is_empty_directory)
{
TEST_CHECK(!is_empty(StaticEnv::Dir));
TEST_CHECK(!is_empty(StaticEnv::SymlinkToDir));
}
TEST_CASE(test_is_empty_directory_dynamic)
{
scoped_test_env env;
TEST_CHECK(is_empty(env.test_root));
env.create_file("foo", 42);
TEST_CHECK(!is_empty(env.test_root));
}
TEST_CASE(test_is_empty_file)
{
TEST_CHECK(is_empty(StaticEnv::EmptyFile));
TEST_CHECK(!is_empty(StaticEnv::NonEmptyFile));
}
TEST_CASE(test_is_empty_fails)
{
scoped_test_env env;
const path dir = env.create_dir("dir");
const path dir2 = env.create_dir("dir/dir2");
permissions(dir, perms::none);
std::error_code ec;
TEST_CHECK(is_empty(dir2, ec) == false);
TEST_CHECK(ec);
TEST_CHECK_THROW(filesystem_error, is_empty(dir2));
}
TEST_CASE(test_directory_access_denied)
{
scoped_test_env env;
const path dir = env.create_dir("dir");
const path file1 = env.create_file("dir/file", 42);
permissions(dir, perms::none);
std::error_code ec = GetTestEC();
TEST_CHECK(is_empty(dir, ec) == false);
TEST_CHECK(ec);
TEST_CHECK(ec != GetTestEC());
TEST_CHECK_THROW(filesystem_error, is_empty(dir));
}
TEST_CASE(test_fifo_fails)
{
scoped_test_env env;
const path fifo = env.create_fifo("fifo");
std::error_code ec = GetTestEC();
TEST_CHECK(is_empty(fifo, ec) == false);
TEST_CHECK(ec);
TEST_CHECK(ec != GetTestEC());
TEST_CHECK_THROW(filesystem_error, is_empty(fifo));
}
TEST_SUITE_END()
|
// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "ash/metrics/user_metrics_recorder.h"
#include <memory>
#include <vector>
#include "ash/login/ui/lock_screen.h"
#include "ash/metrics/demo_session_metrics_recorder.h"
#include "ash/metrics/desktop_task_switch_metric_recorder.h"
#include "ash/metrics/pointer_metrics_recorder.h"
#include "ash/public/cpp/accessibility_controller_enums.h"
#include "ash/public/cpp/ash_pref_names.h"
#include "ash/public/cpp/shelf_item.h"
#include "ash/public/cpp/shelf_model.h"
#include "ash/public/cpp/shell_window_ids.h"
#include "ash/session/session_controller_impl.h"
#include "ash/shelf/shelf.h"
#include "ash/shelf/shelf_view.h"
#include "ash/shell.h"
#include "ash/wm/desks/desks_util.h"
#include "ash/wm/window_state.h"
#include "base/metrics/histogram_macros.h"
#include "base/metrics/user_metrics.h"
#include "components/prefs/pref_service.h"
#include "ui/aura/window.h"
namespace ash {
namespace {
using ::chromeos::WindowStateType;
// Time in seconds between calls to "RecordPeriodicMetrics".
const int kAshPeriodicMetricsTimeInSeconds = 30 * 60;
enum ActiveWindowStateType {
ACTIVE_WINDOW_STATE_TYPE_NO_ACTIVE_WINDOW,
ACTIVE_WINDOW_STATE_TYPE_OTHER,
ACTIVE_WINDOW_STATE_TYPE_MAXIMIZED,
ACTIVE_WINDOW_STATE_TYPE_FULLSCREEN,
ACTIVE_WINDOW_STATE_TYPE_SNAPPED,
ACTIVE_WINDOW_STATE_TYPE_PINNED,
ACTIVE_WINDOW_STATE_TYPE_TRUSTED_PINNED,
ACTIVE_WINDOW_STATE_TYPE_PIP,
ACTIVE_WINDOW_STATE_TYPE_COUNT,
};
ActiveWindowStateType GetActiveWindowState() {
ActiveWindowStateType active_window_state_type =
ACTIVE_WINDOW_STATE_TYPE_NO_ACTIVE_WINDOW;
WindowState* active_window_state = WindowState::ForActiveWindow();
if (active_window_state) {
switch (active_window_state->GetStateType()) {
case WindowStateType::kMaximized:
active_window_state_type = ACTIVE_WINDOW_STATE_TYPE_MAXIMIZED;
break;
case WindowStateType::kFullscreen:
active_window_state_type = ACTIVE_WINDOW_STATE_TYPE_FULLSCREEN;
break;
case WindowStateType::kLeftSnapped:
case WindowStateType::kRightSnapped:
active_window_state_type = ACTIVE_WINDOW_STATE_TYPE_SNAPPED;
break;
case WindowStateType::kPinned:
active_window_state_type = ACTIVE_WINDOW_STATE_TYPE_PINNED;
break;
case WindowStateType::kTrustedPinned:
active_window_state_type = ACTIVE_WINDOW_STATE_TYPE_TRUSTED_PINNED;
break;
case WindowStateType::kPip:
active_window_state_type = ACTIVE_WINDOW_STATE_TYPE_PIP;
break;
case WindowStateType::kDefault:
case WindowStateType::kNormal:
case WindowStateType::kMinimized:
case WindowStateType::kInactive:
case WindowStateType::kAutoPositioned:
active_window_state_type = ACTIVE_WINDOW_STATE_TYPE_OTHER;
break;
}
}
return active_window_state_type;
}
// Returns true if kiosk mode is active.
bool IsKioskModeActive() {
return Shell::Get()->session_controller()->login_status() ==
LoginStatus::KIOSK_APP;
}
// Returns true if there is an active user and their session isn't currently
// locked.
bool IsUserActive() {
SessionControllerImpl* session = Shell::Get()->session_controller();
return session->IsActiveUserSessionStarted() && !session->IsScreenLocked();
}
// Returns a list of window container ids that contain visible windows to be
// counted for UMA statistics. Note the containers are ordered from top most
// visible container to the lowest to allow the |GetNumVisibleWindows| method to
// short circuit when processing a maximized or fullscreen window.
std::vector<int> GetVisibleWindowContainerIds() {
std::vector<int> ids{kShellWindowId_PipContainer,
kShellWindowId_AlwaysOnTopContainer};
// TODO(afakhry): Add metrics for the inactive desks.
ids.emplace_back(desks_util::GetActiveDeskContainerId());
return ids;
}
// Returns an approximate count of how many windows are currently visible in the
// primary root window.
int GetNumVisibleWindowsInPrimaryDisplay() {
int visible_window_count = 0;
bool maximized_or_fullscreen_window_present = false;
for (const int& current_container_id : GetVisibleWindowContainerIds()) {
if (maximized_or_fullscreen_window_present)
break;
const aura::Window::Windows& children =
Shell::GetContainer(Shell::Get()->GetPrimaryRootWindow(),
current_container_id)
->children();
// Reverse iterate over the child windows so that they are processed in
// visible stacking order.
for (aura::Window::Windows::const_reverse_iterator it = children.rbegin(),
rend = children.rend();
it != rend; ++it) {
const aura::Window* child_window = *it;
const WindowState* child_window_state = WindowState::Get(child_window);
if (!child_window->IsVisible() || child_window_state->IsMinimized())
continue;
// Only count activatable windows for 1 reason:
// - Ensures that a browser window and its transient, modal child will
// only count as 1 visible window.
if (child_window_state->CanActivate())
++visible_window_count;
// Stop counting windows that will be hidden by maximized or fullscreen
// windows. Only windows in the active desk container and
// kShellWindowId_AlwaysOnTopContainer can be maximized or fullscreened
// and completely obscure windows beneath them.
if (child_window_state->IsMaximizedOrFullscreenOrPinned()) {
maximized_or_fullscreen_window_present = true;
break;
}
}
}
return visible_window_count;
}
// Records the number of items in the shelf as an UMA statistic.
void RecordShelfItemCounts() {
int pinned_item_count = 0;
int unpinned_item_count = 0;
for (const ShelfItem& item : ShelfModel::Get()->items()) {
if (item.type == TYPE_PINNED_APP || item.type == TYPE_BROWSER_SHORTCUT)
++pinned_item_count;
else
++unpinned_item_count;
}
UMA_HISTOGRAM_COUNTS_100("Ash.Shelf.NumberOfItems",
pinned_item_count + unpinned_item_count);
UMA_HISTOGRAM_COUNTS_100("Ash.Shelf.NumberOfPinnedItems", pinned_item_count);
UMA_HISTOGRAM_COUNTS_100("Ash.Shelf.NumberOfUnpinnedItems",
unpinned_item_count);
}
} // namespace
UserMetricsRecorder::UserMetricsRecorder() {
StartTimer();
login_metrics_recorder_ = std::make_unique<LoginMetricsRecorder>();
}
UserMetricsRecorder::UserMetricsRecorder(bool record_periodic_metrics) {
if (record_periodic_metrics)
StartTimer();
}
UserMetricsRecorder::~UserMetricsRecorder() {
timer_.Stop();
}
// static
void UserMetricsRecorder::RecordUserClickOnTray(
LoginMetricsRecorder::TrayClickTarget target) {
LoginMetricsRecorder* recorder =
Shell::Get()->metrics()->login_metrics_recorder();
recorder->RecordUserTrayClick(target);
}
// static
void UserMetricsRecorder::RecordUserClickOnShelfButton(
LoginMetricsRecorder::ShelfButtonClickTarget target) {
LoginMetricsRecorder* recorder =
Shell::Get()->metrics()->login_metrics_recorder();
recorder->RecordUserShelfButtonClick(target);
}
// static
void UserMetricsRecorder::RecordUserToggleDictation(
DictationToggleSource source) {
UMA_HISTOGRAM_ENUMERATION("Accessibility.CrosDictation.ToggleDictationMethod",
source);
}
void UserMetricsRecorder::RecordUserMetricsAction(UserMetricsAction action) {
using base::RecordAction;
using base::UserMetricsAction;
switch (action) {
case UMA_DESKTOP_SWITCH_TASK:
RecordAction(UserMetricsAction("Desktop_SwitchTask"));
task_switch_metrics_recorder_.OnTaskSwitch(TaskSwitchSource::DESKTOP);
break;
case UMA_LAUNCHER_BUTTON_PRESSED_WITH_MOUSE:
RecordAction(UserMetricsAction("Launcher_ButtonPressed_Mouse"));
break;
case UMA_LAUNCHER_BUTTON_PRESSED_WITH_TOUCH:
RecordAction(UserMetricsAction("Launcher_ButtonPressed_Touch"));
break;
case UMA_LAUNCHER_CLICK_ON_APP:
RecordAction(UserMetricsAction("Launcher_ClickOnApp"));
break;
case UMA_LAUNCHER_CLICK_ON_APPLIST_BUTTON:
RecordAction(UserMetricsAction("Launcher_ClickOnApplistButton"));
break;
case UMA_LAUNCHER_LAUNCH_TASK:
RecordAction(UserMetricsAction("Launcher_LaunchTask"));
task_switch_metrics_recorder_.OnTaskSwitch(TaskSwitchSource::SHELF);
break;
case UMA_LAUNCHER_MINIMIZE_TASK:
RecordAction(UserMetricsAction("Launcher_MinimizeTask"));
break;
case UMA_LAUNCHER_SWITCH_TASK:
RecordAction(UserMetricsAction("Launcher_SwitchTask"));
task_switch_metrics_recorder_.OnTaskSwitch(TaskSwitchSource::SHELF);
break;
case UMA_SHELF_ALIGNMENT_SET_BOTTOM:
RecordAction(UserMetricsAction("Shelf_AlignmentSetBottom"));
break;
case UMA_SHELF_ALIGNMENT_SET_LEFT:
RecordAction(UserMetricsAction("Shelf_AlignmentSetLeft"));
break;
case UMA_SHELF_ALIGNMENT_SET_RIGHT:
RecordAction(UserMetricsAction("Shelf_AlignmentSetRight"));
break;
case UMA_SHELF_ITEM_PINNED:
RecordAction(UserMetricsAction("Shelf_ItemPinned"));
break;
case UMA_SHELF_ITEM_UNPINNED:
RecordAction(UserMetricsAction("Shelf_ItemUnpinned"));
break;
case UMA_STATUS_AREA_AUDIO_CURRENT_INPUT_DEVICE:
RecordAction(UserMetricsAction("StatusArea_Audio_CurrentInputDevice"));
break;
case UMA_STATUS_AREA_AUDIO_CURRENT_OUTPUT_DEVICE:
RecordAction(UserMetricsAction("StatusArea_Audio_CurrentOutputDevice"));
break;
case UMA_STATUS_AREA_AUDIO_SWITCH_INPUT_DEVICE:
RecordAction(UserMetricsAction("StatusArea_Audio_SwitchInputDevice"));
break;
case UMA_STATUS_AREA_AUDIO_SWITCH_OUTPUT_DEVICE:
RecordAction(UserMetricsAction("StatusArea_Audio_SwitchOutputDevice"));
break;
case UMA_STATUS_AREA_BRIGHTNESS_CHANGED:
RecordAction(UserMetricsAction("StatusArea_BrightnessChanged"));
break;
case UMA_STATUS_AREA_BLUETOOTH_DISABLED:
RecordAction(UserMetricsAction("StatusArea_Bluetooth_Disabled"));
break;
case UMA_STATUS_AREA_BLUETOOTH_ENABLED:
RecordAction(UserMetricsAction("StatusArea_Bluetooth_Enabled"));
break;
case UMA_STATUS_AREA_CAPS_LOCK_DETAILED:
RecordAction(UserMetricsAction("StatusArea_CapsLock_Detailed"));
break;
case UMA_STATUS_AREA_CAPS_LOCK_DISABLED_BY_CLICK:
RecordAction(UserMetricsAction("StatusArea_CapsLock_DisabledByClick"));
break;
case UMA_STATUS_AREA_CAPS_LOCK_ENABLED_BY_CLICK:
RecordAction(UserMetricsAction("StatusArea_CapsLock_EnabledByClick"));
break;
case UMA_STATUS_AREA_CAPS_LOCK_POPUP:
RecordAction(UserMetricsAction("StatusArea_CapsLock_Popup"));
break;
case UMA_STATUS_AREA_CAST_STOP_CAST:
RecordAction(UserMetricsAction("StatusArea_Cast_StopCast"));
break;
case UMA_STATUS_AREA_CONNECT_TO_CONFIGURED_NETWORK:
RecordAction(UserMetricsAction("StatusArea_Network_ConnectConfigured"));
break;
case UMA_STATUS_AREA_CONNECT_TO_UNCONFIGURED_NETWORK:
RecordAction(UserMetricsAction("StatusArea_Network_ConnectUnconfigured"));
break;
case UMA_STATUS_AREA_CONNECT_TO_VPN:
RecordAction(UserMetricsAction("StatusArea_VPN_ConnectToNetwork"));
break;
case UMA_STATUS_AREA_CHANGED_VOLUME_MENU:
RecordAction(UserMetricsAction("StatusArea_Volume_ChangedMenu"));
break;
case UMA_STATUS_AREA_CHANGED_VOLUME_POPUP:
RecordAction(UserMetricsAction("StatusArea_Volume_ChangedPopup"));
break;
case UMA_STATUS_AREA_DETAILED_ACCESSIBILITY:
RecordAction(UserMetricsAction("StatusArea_Accessability_DetailedView"));
break;
case UMA_STATUS_AREA_DETAILED_AUDIO_VIEW:
RecordAction(UserMetricsAction("StatusArea_Audio_Detailed"));
break;
case UMA_STATUS_AREA_DETAILED_BLUETOOTH_VIEW:
RecordAction(UserMetricsAction("StatusArea_Bluetooth_Detailed"));
break;
case UMA_STATUS_AREA_DETAILED_BRIGHTNESS_VIEW:
RecordAction(UserMetricsAction("StatusArea_Brightness_Detailed"));
break;
case UMA_STATUS_AREA_DETAILED_CAST_VIEW:
RecordAction(UserMetricsAction("StatusArea_Cast_Detailed"));
break;
case UMA_STATUS_AREA_DETAILED_CAST_VIEW_LAUNCH_CAST:
RecordAction(UserMetricsAction("StatusArea_Cast_Detailed_Launch_Cast"));
break;
case UMA_STATUS_AREA_DETAILED_DRIVE_VIEW:
RecordAction(UserMetricsAction("StatusArea_Drive_Detailed"));
break;
case UMA_STATUS_AREA_DETAILED_NETWORK_VIEW:
RecordAction(UserMetricsAction("StatusArea_Network_Detailed"));
break;
case UMA_STATUS_AREA_DETAILED_SMS_VIEW:
RecordAction(UserMetricsAction("StatusArea_SMS_Detailed"));
break;
case UMA_STATUS_AREA_DETAILED_VPN_VIEW:
RecordAction(UserMetricsAction("StatusArea_VPN_Detailed"));
break;
case UMA_STATUS_AREA_DISPLAY_DEFAULT_SELECTED:
RecordAction(UserMetricsAction("StatusArea_Display_Default_Selected"));
break;
case UMA_STATUS_AREA_DISPLAY_DEFAULT_SHOW_SETTINGS:
RecordAction(
UserMetricsAction("StatusArea_Display_Default_ShowSettings"));
break;
case UMA_STATUS_AREA_DISPLAY_NOTIFICATION_CREATED:
RecordAction(
UserMetricsAction("StatusArea_Display_Notification_Created"));
break;
case UMA_STATUS_AREA_DISPLAY_NOTIFICATION_SELECTED:
RecordAction(
UserMetricsAction("StatusArea_Display_Notification_Selected"));
break;
case UMA_STATUS_AREA_DISPLAY_NOTIFICATION_SHOW_SETTINGS:
RecordAction(
UserMetricsAction("StatusArea_Display_Notification_Show_Settings"));
break;
case UMA_STATUS_AREA_DISABLE_WIFI:
RecordAction(UserMetricsAction("StatusArea_Network_WifiDisabled"));
break;
case UMA_STATUS_AREA_DRIVE_CANCEL_OPERATION:
RecordAction(UserMetricsAction("StatusArea_Drive_CancelOperation"));
break;
case UMA_STATUS_AREA_DRIVE_SETTINGS:
RecordAction(UserMetricsAction("StatusArea_Drive_Settings"));
break;
case UMA_STATUS_AREA_ENABLE_WIFI:
RecordAction(UserMetricsAction("StatusArea_Network_WifiEnabled"));
break;
case UMA_STATUS_AREA_MENU_OPENED:
RecordAction(UserMetricsAction("StatusArea_MenuOpened"));
break;
case UMA_STATUS_AREA_NETWORK_JOIN_OTHER_CLICKED:
RecordAction(UserMetricsAction("StatusArea_Network_JoinOther"));
break;
case UMA_STATUS_AREA_NETWORK_SETTINGS_OPENED:
RecordAction(UserMetricsAction("StatusArea_Network_Settings"));
break;
case UMA_STATUS_AREA_OS_UPDATE_DEFAULT_SELECTED:
RecordAction(UserMetricsAction("StatusArea_OS_Update_Default_Selected"));
break;
case UMA_STATUS_AREA_SCREEN_CAPTURE_CHANGE_SOURCE:
RecordAction(UserMetricsAction("StatusArea_ScreenCapture_Change_Source"));
break;
case UMA_STATUS_AREA_SCREEN_CAPTURE_DEFAULT_STOP:
RecordAction(UserMetricsAction("StatusArea_ScreenCapture_Default_Stop"));
break;
case UMA_STATUS_AREA_SCREEN_CAPTURE_NOTIFICATION_STOP:
RecordAction(
UserMetricsAction("StatusArea_ScreenCapture_Notification_Stop"));
break;
case UMA_STATUS_AREA_SHOW_NETWORK_CONNECTION_DETAILS:
RecordAction(UserMetricsAction("StatusArea_Network_ConnectionDetails"));
break;
case UMA_STATUS_AREA_SHOW_VPN_CONNECTION_DETAILS:
RecordAction(UserMetricsAction("StatusArea_VPN_ConnectionDetails"));
break;
case UMA_STATUS_AREA_SIGN_OUT:
RecordAction(UserMetricsAction("StatusArea_SignOut"));
break;
case UMA_STATUS_AREA_SMS_DETAILED_DISMISS_MSG:
RecordAction(UserMetricsAction("StatusArea_SMS_Detailed_DismissMsg"));
break;
case UMA_STATUS_AREA_SMS_NOTIFICATION_DISMISS_MSG:
RecordAction(UserMetricsAction("StatusArea_SMS_Notification_DismissMsg"));
break;
case UMA_STATUS_AREA_TRACING_DEFAULT_SELECTED:
RecordAction(UserMetricsAction("StatusArea_Tracing_Default_Selected"));
break;
case UMA_STATUS_AREA_VPN_ADD_BUILT_IN_CLICKED:
RecordAction(UserMetricsAction("StatusArea_VPN_AddBuiltIn"));
break;
case UMA_STATUS_AREA_VPN_ADD_THIRD_PARTY_CLICKED:
RecordAction(UserMetricsAction("StatusArea_VPN_AddThirdParty"));
break;
case UMA_STATUS_AREA_VPN_DISCONNECT_CLICKED:
RecordAction(UserMetricsAction("StatusArea_VPN_Disconnect"));
break;
case UMA_STATUS_AREA_VPN_SETTINGS_OPENED:
RecordAction(UserMetricsAction("StatusArea_VPN_Settings"));
break;
case UMA_TRAY_HELP:
RecordAction(UserMetricsAction("Tray_Help"));
break;
case UMA_TRAY_LOCK_SCREEN:
RecordAction(UserMetricsAction("Tray_LockScreen"));
break;
case UMA_TRAY_NIGHT_LIGHT:
RecordAction(UserMetricsAction("Tray_NightLight"));
break;
case UMA_TRAY_OVERVIEW:
RecordAction(UserMetricsAction("Tray_Overview"));
break;
case UMA_TRAY_SETTINGS:
RecordAction(UserMetricsAction("Tray_Settings"));
break;
case UMA_TRAY_SHUT_DOWN:
RecordAction(UserMetricsAction("Tray_ShutDown"));
break;
}
}
void UserMetricsRecorder::StartDemoSessionMetricsRecording() {
demo_session_metrics_recorder_ =
std::make_unique<DemoSessionMetricsRecorder>();
}
void UserMetricsRecorder::OnShellInitialized() {
// Lazy creation of the DesktopTaskSwitchMetricRecorder because it accesses
// Shell::Get() which is not available when |this| is instantiated.
if (!desktop_task_switch_metric_recorder_) {
desktop_task_switch_metric_recorder_.reset(
new DesktopTaskSwitchMetricRecorder());
}
pointer_metrics_recorder_ = std::make_unique<PointerMetricsRecorder>();
}
void UserMetricsRecorder::OnShellShuttingDown() {
demo_session_metrics_recorder_.reset();
desktop_task_switch_metric_recorder_.reset();
// To clean up pointer_metrics_recorder_ properly, a valid shell instance is
// required, so explicitly delete it before the shell instance becomes
// invalid.
pointer_metrics_recorder_.reset();
}
void UserMetricsRecorder::RecordPeriodicMetrics() {
Shelf* shelf = Shelf::ForWindow(Shell::GetPrimaryRootWindow());
// TODO(bruthig): Investigating whether the check for |manager| is necessary
// and add tests if it is.
if (shelf) {
// TODO(bruthig): Consider tracking the time spent in each alignment.
UMA_HISTOGRAM_ENUMERATION("Ash.ShelfAlignmentOverTime",
static_cast<ShelfAlignmentUmaEnumValue>(
shelf->SelectValueForShelfAlignment(
SHELF_ALIGNMENT_UMA_ENUM_VALUE_BOTTOM,
SHELF_ALIGNMENT_UMA_ENUM_VALUE_LEFT,
SHELF_ALIGNMENT_UMA_ENUM_VALUE_RIGHT)),
SHELF_ALIGNMENT_UMA_ENUM_VALUE_COUNT);
}
if (IsUserInActiveDesktopEnvironment()) {
RecordShelfItemCounts();
UMA_HISTOGRAM_COUNTS_100("Ash.NumberOfVisibleWindowsInPrimaryDisplay",
GetNumVisibleWindowsInPrimaryDisplay());
base::UmaHistogramBoolean(
"Ash.AppNotificationBadgingPref",
Shell::Get()->session_controller()->GetActivePrefService()->GetBoolean(
prefs::kAppNotificationBadgingEnabled));
}
// TODO(bruthig): Find out if this should only be logged when the user is
// active.
// TODO(bruthig): Consider tracking how long a particular type of window is
// active at a time.
UMA_HISTOGRAM_ENUMERATION("Ash.ActiveWindowShowTypeOverTime",
GetActiveWindowState(),
ACTIVE_WINDOW_STATE_TYPE_COUNT);
}
bool UserMetricsRecorder::IsUserInActiveDesktopEnvironment() const {
return IsUserActive() && !IsKioskModeActive();
}
void UserMetricsRecorder::StartTimer() {
timer_.Start(FROM_HERE,
base::TimeDelta::FromSeconds(kAshPeriodicMetricsTimeInSeconds),
this, &UserMetricsRecorder::RecordPeriodicMetrics);
}
} // namespace ash
|
; A130260: Minimal index k of an even Fibonacci number A001906 such that A001906(k) = Fib(2k) >= n (the 'upper' even Fibonacci Inverse).
; 0,1,2,2,3,3,3,3,3,4,4,4,4,4,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7
mov $2,$0
lpb $0
sub $0,$3
trn $0,1
add $1,1
add $3,$2
sub $3,$0
lpe
|
; A010737: a(n) = 2*a(n-2) + 1.
; 4,6,9,13,19,27,39,55,79,111,159,223,319,447,639,895,1279,1791,2559,3583,5119,7167,10239,14335,20479,28671,40959,57343,81919,114687,163839,229375,327679,458751,655359
add $0,1
mov $3,4
lpb $0,1
sub $0,1
trn $1,$2
add $1,$3
mov $4,$2
sub $2,$2
add $3,$1
add $2,$3
sub $2,2
mov $3,6
trn $4,3
add $3,$4
lpe
|
; A015536: Expansion of x/(1-5*x-3*x^2).
; 0,1,5,28,155,859,4760,26377,146165,809956,4488275,24871243,137821040,763718929,4232057765,23451445612,129953401355,720121343611,3990466922120,22112698641433,122534893973525,679012565791924,3762667510880195,20850375251776747,115539878791524320,640250519712951841,3547872234939332165,19660112733835516348,108944180373995578235,603701240071484440219,3345338741479408935800,18537797427611497999657,102725003362495716805685,569238409095313078027396,3154367055564052540554035,17479550505106201936852363,96860853692223167305923920,536742919976434442340176689,2974297160958841713618655205,16481714564723511895113806092,91331464306494084616424996075,506102465226640958767466398651,2804506719052687047686606981480,15540840990943358114735434103353,86117725111874851716736991461205,477211148532204332927891259616084,2644408917996646219789667272464035,14653678035579844097732010141168427,81201616931889159148029052523234240,449969118766185328033341293039676481
mov $2,$0
mov $3,1
lpb $2
mov $0,$3
mul $0,3
sub $2,1
add $4,$3
add $3,$4
add $3,$0
mov $4,$0
lpe
div $0,3
|
;;
;; Copyright (c) 2012-2020, Intel Corporation
;;
;; Redistribution and use in source and binary forms, with or without
;; modification, are permitted provided that the following conditions are met:
;;
;; * Redistributions of source code must retain the above copyright notice,
;; this list of conditions and the following disclaimer.
;; * Redistributions in binary form must reproduce the above copyright
;; notice, this list of conditions and the following disclaimer in the
;; documentation and/or other materials provided with the distribution.
;; * Neither the name of Intel Corporation nor the names of its contributors
;; may be used to endorse or promote products derived from this software
;; without specific prior written permission.
;;
;; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
;; AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
;; IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
;; DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
;; FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
;; DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
;; SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
;; CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
;; OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
;; OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
;;
%define FUNC flush_job_hmac_sha_384_avx2
%define SHA_X_DIGEST_SIZE 384
%include "avx2/mb_mgr_hmac_sha_512_flush_avx2.asm"
|
###############################################################################
# Copyright 2019 Intel Corporation
# All Rights Reserved.
#
# If this software was obtained under the Intel Simplified Software License,
# the following terms apply:
#
# The source code, information and material ("Material") contained herein is
# owned by Intel Corporation or its suppliers or licensors, and title to such
# Material remains with Intel Corporation or its suppliers or licensors. The
# Material contains proprietary information of Intel or its suppliers and
# licensors. The Material is protected by worldwide copyright laws and treaty
# provisions. No part of the Material may be used, copied, reproduced,
# modified, published, uploaded, posted, transmitted, distributed or disclosed
# in any way without Intel's prior express written permission. No license under
# any patent, copyright or other intellectual property rights in the Material
# is granted to or conferred upon you, either expressly, by implication,
# inducement, estoppel or otherwise. Any license under such intellectual
# property rights must be express and approved by Intel in writing.
#
# Unless otherwise agreed by Intel in writing, you may not remove or alter this
# notice or any other notice embedded in Materials by Intel or Intel's
# suppliers or licensors in any way.
#
#
# If this software was obtained under the Apache License, Version 2.0 (the
# "License"), the following terms apply:
#
# You may not use this file except in compliance with the License. You may
# obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
#
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#
# See the License for the specific language governing permissions and
# limitations under the License.
###############################################################################
.section .note.GNU-stack,"",%progbits
.text
.p2align 5, 0x90
.globl cpAdd_BNU
.type cpAdd_BNU, @function
cpAdd_BNU:
push %ebp
mov %esp, %ebp
push %ebx
push %esi
push %edi
movl (12)(%ebp), %eax
movl (16)(%ebp), %ebx
movl (8)(%ebp), %edx
movl (20)(%ebp), %edi
shl $(2), %edi
xor %ecx, %ecx
pandn %mm0, %mm0
.p2align 5, 0x90
.Lmain_loopgas_1:
movd (%ecx,%eax), %mm1
movd (%ebx,%ecx), %mm2
paddq %mm1, %mm0
paddq %mm2, %mm0
movd %mm0, (%edx,%ecx)
pshufw $(254), %mm0, %mm0
add $(4), %ecx
cmp %edi, %ecx
jl .Lmain_loopgas_1
movd %mm0, %eax
emms
pop %edi
pop %esi
pop %ebx
pop %ebp
ret
.Lfe1:
.size cpAdd_BNU, .Lfe1-(cpAdd_BNU)
|
/* Copyright 2021 Aristocratos (jakob@qvantnet.com)
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
indent = tab
tab-size = 4
*/
#pragma once
#include <string>
#include <vector>
#include <array>
#include <regex>
#include <atomic>
#include <filesystem>
#include <ranges>
#include <chrono>
#include <thread>
#include <tuple>
#include <pthread.h>
using std::string, std::vector, std::atomic, std::to_string, std::regex, std::tuple, std::array;
//? ------------------------------------------------- NAMESPACES ------------------------------------------------------
//* Collection of escape codes for text style and formatting
namespace Fx {
const string e = "\x1b["; //* Escape sequence start
const string b = e + "1m"; //* Bold on/off
const string ub = e + "22m"; //* Bold off
const string d = e + "2m"; //* Dark on
const string ud = e + "22m"; //* Dark off
const string i = e + "3m"; //* Italic on
const string ui = e + "23m"; //* Italic off
const string ul = e + "4m"; //* Underline on
const string uul = e + "24m"; //* Underline off
const string bl = e + "5m"; //* Blink on
const string ubl = e + "25m"; //* Blink off
const string s = e + "9m"; //* Strike/crossed-out on
const string us = e + "29m"; //* Strike/crossed-out on/off
//* Reset foreground/background color and text effects
const string reset_base = e + "0m";
//* Reset text effects and restore theme foregrund and background color
extern string reset;
//* Regex for matching color, style and cursor move escape sequences
const regex escape_regex("\033\\[\\d+;?\\d?;?\\d*;?\\d*;?\\d*(m|f|s|u|C|D|A|B){1}");
//* Regex for matching only color and style escape sequences
const regex color_regex("\033\\[\\d+;?\\d?;?\\d*;?\\d*;?\\d*(m){1}");
//* Return a string with all colors and text styling removed
inline string uncolor(const string& s) { return regex_replace(s, color_regex, ""); }
}
//* Collection of escape codes and functions for cursor manipulation
namespace Mv {
//* Move cursor to <line>, <column>
inline string to(const int& line, const int& col) { return Fx::e + to_string(line) + ';' + to_string(col) + 'f'; }
//* Move cursor right <x> columns
inline string r(const int& x) { return Fx::e + to_string(x) + 'C'; }
//* Move cursor left <x> columns
inline string l(const int& x) { return Fx::e + to_string(x) + 'D'; }
//* Move cursor up x lines
inline string u(const int& x) { return Fx::e + to_string(x) + 'A'; }
//* Move cursor down x lines
inline string d(const int& x) { return Fx::e + to_string(x) + 'B'; }
//* Save cursor position
const string save = Fx::e + "s";
//* Restore saved cursor postion
const string restore = Fx::e + "u";
}
//* Collection of escape codes and functions for terminal manipulation
namespace Term {
extern atomic<bool> initialized;
extern atomic<int> width;
extern atomic<int> height;
extern string fg, bg, current_tty;
const string hide_cursor = Fx::e + "?25l";
const string show_cursor = Fx::e + "?25h";
const string alt_screen = Fx::e + "?1049h";
const string normal_screen = Fx::e + "?1049l";
const string clear = Fx::e + "2J" + Fx::e + "0;0f";
const string clear_end = Fx::e + "0J";
const string clear_begin = Fx::e + "1J";
const string mouse_on = Fx::e + "?1002h" + Fx::e + "?1015h" + Fx::e + "?1006h"; //? Enable reporting of mouse position on click and release
const string mouse_off = Fx::e + "?1002l";
const string mouse_direct_on = Fx::e + "?1003h"; //? Enable reporting of mouse position at any movement
const string mouse_direct_off = Fx::e + "?1003l";
const string sync_start = Fx::e + "?2026h"; //? Start of terminal synchronized output
const string sync_end = Fx::e + "?2026l"; //? End of terminal synchronized output
//* Returns true if terminal has been resized and updates width and height
bool refresh(bool only_check=false);
//* Returns an array with the lowest possible width, height with current box config
auto get_min_size(const string& boxes) -> array<int, 2>;
//* Check for a valid tty, save terminal options and set new options
bool init();
//* Restore terminal options
void restore();
}
//? --------------------------------------------------- FUNCTIONS -----------------------------------------------------
namespace Tools {
constexpr auto SSmax = std::numeric_limits<std::streamsize>::max();
extern atomic<int> active_locks;
//* Return number of UTF8 characters in a string (wide=true counts UTF-8 characters with a width > 1 as 2 characters)
inline size_t ulen(const string& str, const bool wide=false) {
return std::ranges::count_if(str, [](char c) { return (static_cast<unsigned char>(c) & 0xC0) != 0x80; })
+ (wide ? std::ranges::count_if(str, [](char c) { return (static_cast<unsigned char>(c) > 0xef); }) : 0);
}
//* Resize a string consisting of UTF8 characters (only reduces size)
string uresize(const string str, const size_t len, const bool wide=false);
//* Resize a string consisting of UTF8 characters from left (only reduces size)
string luresize(const string str, const size_t len, const bool wide=false);
//* Replace <from> in <str> with <to> and return new string
string s_replace(const string& str, const string& from, const string& to);
//* Capatilize <str>
inline string capitalize(string str) {
str.at(0) = toupper(str.at(0));
return str;
}
//* Return <str> with only uppercase characters
inline string str_to_upper(string str) {
std::ranges::for_each(str, [](auto& c) { c = ::toupper(c); } );
return str;
}
//* Return <str> with only lowercase characters
inline string str_to_lower(string str) {
std::ranges::for_each(str, [](char& c) { c = ::tolower(c); } );
return str;
}
//* Check if vector <vec> contains value <find_val>
template <typename T, typename T2>
inline bool v_contains(const vector<T>& vec, const T2& find_val) {
return std::ranges::find(vec, find_val) != vec.end();
}
//* Check if string <str> contains value <find_val>
template <typename T>
inline bool s_contains(const string& str, const T& find_val) {
return str.find(find_val) != string::npos;
}
//* Return index of <find_val> from vector <vec>, returns size of <vec> if <find_val> is not present
template <typename T>
inline size_t v_index(const vector<T>& vec, const T& find_val) {
return std::ranges::distance(vec.begin(), std::ranges::find(vec, find_val));
}
//* Compare <first> with all following values
template<typename First, typename ... T>
inline bool is_in(const First& first, const T& ... t) {
return ((first == t) or ...);
}
//* Return current time since epoch in seconds
inline uint64_t time_s() {
return std::chrono::duration_cast<std::chrono::seconds>(std::chrono::system_clock::now().time_since_epoch()).count();
}
//* Return current time since epoch in milliseconds
inline uint64_t time_ms() {
return std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now().time_since_epoch()).count();
}
//* Return current time since epoch in microseconds
inline uint64_t time_micros() {
return std::chrono::duration_cast<std::chrono::microseconds>(std::chrono::system_clock::now().time_since_epoch()).count();
}
//* Check if a string is a valid bool value
inline bool isbool(const string& str) {
return is_in(str, "true", "false", "True", "False");
}
//* Convert string to bool, returning any value not equal to "true" or "True" as false
inline bool stobool(const string& str) {
return is_in(str, "true", "True");
}
//* Check if a string is a valid integer value (only postive)
inline bool isint(const string& str) {
return all_of(str.begin(), str.end(), ::isdigit);
}
//* Left-trim <t_str> from <str> and return new string
string ltrim(const string& str, const string& t_str = " ");
//* Right-trim <t_str> from <str> and return new string
string rtrim(const string& str, const string& t_str = " ");
//* Left/right-trim <t_str> from <str> and return new string
inline string trim(const string& str, const string& t_str = " ") {
return ltrim(rtrim(str, t_str), t_str);
}
//* Split <string> at all occurrences of <delim> and return as vector of strings
auto ssplit(const string& str, const char& delim = ' ') -> vector<string>;
//* Put current thread to sleep for <ms> milliseconds
inline void sleep_ms(const size_t& ms) { std::this_thread::sleep_for(std::chrono::milliseconds(ms)); }
//* Put current thread to sleep for <micros> microseconds
inline void sleep_micros(const size_t& micros) { std::this_thread::sleep_for(std::chrono::microseconds(micros)); }
//* Left justify string <str> if <x> is greater than <str> length, limit return size to <x> by default
string ljust(string str, const size_t x, const bool utf=false, const bool wide=false, const bool limit=true);
//* Right justify string <str> if <x> is greater than <str> length, limit return size to <x> by default
string rjust(string str, const size_t x, const bool utf=false, const bool wide=false, const bool limit=true);
//* Center justify string <str> if <x> is greater than <str> length, limit return size to <x> by default
string cjust(string str, const size_t x, const bool utf=false, const bool wide=false, const bool limit=true);
//* Replace whitespaces " " with escape code for move right
string trans(const string& str);
//* Convert seconds to format "<days>d <hours>:<minutes>:<seconds>" and return string
string sec_to_dhms(size_t seconds, bool no_days=false, bool no_seconds=false);
//* Scales up in steps of 1024 to highest positive value unit and returns string with unit suffixed
//* bit=True or defaults to bytes
//* start=int to set 1024 multiplier starting unit
//* short=True always returns 0 decimals and shortens unit to 1 character
string floating_humanizer(uint64_t value, const bool shorten=false, size_t start=0, const bool bit=false, const bool per_second=false);
//* Add std::string operator * : Repeat string <str> <n> number of times
std::string operator*(const string& str, int64_t n);
//* Return current time in <strf> format
string strf_time(const string& strf);
string hostname();
string username();
static inline void busy_wait (void) {
#if defined __i386__ || defined __x86_64__
__builtin_ia32_pause();
#elif defined __ia64__
__asm volatile("hint @pause" : : : "memory");
#elif defined __sparc__ && (defined __arch64__ || defined __sparc_v9__)
__asm volatile("membar #LoadLoad" : : : "memory");
#else
__asm volatile("" : : : "memory");
#endif
}
void atomic_wait(const atomic<bool>& atom, const bool old=true) noexcept;
void atomic_wait_for(const atomic<bool>& atom, const bool old=true, const uint64_t wait_ms=0) noexcept;
//* Waits for atomic<bool> to be false and sets it to true on construct, sets to false on destruct
class atomic_lock {
atomic<bool>& atom;
bool not_true = false;
public:
atomic_lock(atomic<bool>& atom);
~atomic_lock();
};
//* Read a complete file and return as a string
string readfile(const std::filesystem::path& path, const string& fallback="");
//* Convert a celsius value to celsius, fahrenheit, kelvin or rankin and return tuple with new value and unit.
auto celsius_to(const long long& celsius, const string& scale) -> tuple<long long, string>;
}
//* Simple logging implementation
namespace Logger {
const vector<string> log_levels = {
"DISABLED",
"ERROR",
"WARNING",
"INFO",
"DEBUG",
};
extern std::filesystem::path logfile;
//* Set log level, valid arguments: "DISABLED", "ERROR", "WARNING", "INFO" and "DEBUG"
void set(const string& level);
void log_write(const size_t level, const string& msg);
inline void error(const string msg) { log_write(1, msg); }
inline void warning(const string msg) { log_write(2, msg); }
inline void info(const string msg) { log_write(3, msg); }
inline void debug(const string msg) { log_write(4, msg); }
}
|
db "FIRE HORSE@" ; species name
db "Training by"
next "jumping over grass"
next "that grows longer"
page "every day has made"
next "it a world-class"
next "jumper.@"
|
//===-- SparcTargetInfo.cpp - Sparc Target Implementation -----------------===//
//
// 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
//
//===----------------------------------------------------------------------===//
#include "Sparc.h"
#include "llvm/IR/Module.h"
#include "llvm/Support/TargetRegistry.h"
using namespace llvm;
Target &llvm::getTheSparcTarget() {
static Target TheSparcTarget;
return TheSparcTarget;
}
Target &llvm::getTheSparcV9Target() {
static Target TheSparcV9Target;
return TheSparcV9Target;
}
Target &llvm::getTheSparcelTarget() {
static Target TheSparcelTarget;
return TheSparcelTarget;
}
extern "C" void LLVMInitializeSparcTargetInfo() {
RegisterTarget<Triple::sparc, /*HasJIT=*/true> X(getTheSparcTarget(), "sparc",
"Sparc", "Sparc");
RegisterTarget<Triple::sparcv9, /*HasJIT=*/true> Y(
getTheSparcV9Target(), "sparcv9", "Sparc V9", "Sparc");
RegisterTarget<Triple::sparcel, /*HasJIT=*/true> Z(
getTheSparcelTarget(), "sparcel", "Sparc LE", "Sparc");
}
|
#pragma once
namespace Big::UserInterface
{
enum class OptionAction
{
LeftPress,
RightPress,
EnterPress
};
enum class OptionFlag
{
Horizontal = (1 << 0),
Enterable = (1 << 1)
};
class AbstractOption
{
public:
virtual ~AbstractOption() noexcept = default;
virtual const char* GetLeftText() = 0;
virtual const char* GetRightText() = 0;
virtual const char* GetDescription() = 0;
virtual void HandleAction(OptionAction action) = 0;
virtual bool GetFlag(OptionFlag flag) = 0;
protected:
explicit AbstractOption() = default;
AbstractOption(AbstractOption const&) = default;
AbstractOption& operator=(AbstractOption const&) = default;
AbstractOption(AbstractOption&&) = default;
AbstractOption& operator=(AbstractOption&&) = default;
};
}
|
; A021136: Decimal expansion of 1/132.
; 0,0,7,5,7,5,7,5,7,5,7,5,7,5,7,5,7,5,7,5,7,5,7,5,7,5,7,5,7,5,7,5,7,5,7,5,7,5,7,5,7,5,7,5,7,5,7,5,7,5,7,5,7,5,7,5,7,5,7,5,7,5,7,5,7,5,7,5,7,5,7,5,7,5,7,5,7,5,7,5,7,5,7,5,7,5,7,5,7,5,7,5,7,5,7,5,7,5,7
pow $0,3
lpb $0
gcd $0,2
mul $0,2
add $1,$0
add $1,3
lpe
mov $0,$1
|
.data
val: .word 0x12345678 0x456789ab
.text
main:
la x1, val
li x2, 0xDEADBABA
li x3, 0x8BADF00D
sw x2, 0(x1)
sw x3, 4(x1)
addi x1, x1, 8
sw x3, 0(x1)
addi x1, x1, -8
lw x4, 0(x1)
lw x5, 4(x1)
lw x6, 8(x1)
halt: beq x0, x0, halt
|
/*
* This file Copyright (C) Mnemosyne LLC
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2
* as published by the Free Software Foundation.
*
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
*
* $Id: license.cc 11092 2010-08-01 20:36:13Z charles $
*/
#include <QDialogButtonBox>
#include <QPlainTextEdit>
#include <QVBoxLayout>
#include "license.h"
LicenseDialog :: LicenseDialog( QWidget * parent ):
QDialog( parent, Qt::Dialog )
{
setWindowTitle( tr( "License" ) );
resize( 400, 300 );
QVBoxLayout * v = new QVBoxLayout( this );
QPlainTextEdit * t = new QPlainTextEdit( this );
t->setReadOnly( true );
t->setPlainText(
"The OS X client, CLI client, and parts of libtransmission are licensed under the terms of the MIT license.\n\n"
"The Transmission daemon, GTK+ client, Qt client, Web client, and most of libtransmission are licensed under the terms of the GNU GPL version 2, with two special exceptions:\n\n"
"1. The MIT-licensed portions of Transmission listed above are exempt from GPLv2 clause 2(b) and may retain their MIT license.\n\n"
"2. Permission is granted to link the code in this release with the OpenSSL project's 'OpenSSL' library and to distribute the linked executables. Works derived from Transmission may, at their authors' discretion, keep or delete this exception." );
v->addWidget( t );
QDialogButtonBox * box = new QDialogButtonBox;
box->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed );
box->setOrientation( Qt::Horizontal );
box->setStandardButtons( QDialogButtonBox::Close );
v->addWidget( box );
connect( box, SIGNAL(rejected()), this, SLOT(hide()) );
}
|
#include "../../pch.h"
using namespace std::string_literals;
using namespace Library;
#define TEST(name) TEST_CASE_METHOD(MemLeak, "Memory::" #name, "[Memory]")
namespace UnitTests
{
TEST(Malloc)
{
REQUIRE(!Memory::Malloc(0));
}
}
|
; A187340: Hankel transform of A014301(n+1).
; 1,2,5,5,-2,-11,-11,2,17,17,-2,-23,-23,2,29,29,-2,-35,-35,2,41,41,-2,-47,-47,2,53,53,-2,-59,-59,2,65,65,-2,-71,-71,2,77,77,-2,-83,-83,2,89,89,-2,-95,-95,2,101,101,-2,-107,-107,2,113,113,-2,-119,-119
lpb $0
sub $2,$0
sub $0,1
sub $1,$2
add $2,$1
add $1,$0
lpe
add $1,1
mov $0,$1
|
////////////////////////////////////////////////////////////////////////////////
/// DISCLAIMER
///
/// Copyright 2014-2016 ArangoDB GmbH, Cologne, Germany
/// Copyright 2004-2014 triAGENS GmbH, Cologne, Germany
///
/// Licensed under the Apache License, Version 2.0 (the "License");
/// you may not use this file except in compliance with the License.
/// You may obtain a copy of the License at
///
/// http://www.apache.org/licenses/LICENSE-2.0
///
/// Unless required by applicable law or agreed to in writing, software
/// distributed under the License is distributed on an "AS IS" BASIS,
/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
/// See the License for the specific language governing permissions and
/// limitations under the License.
///
/// Copyright holder is ArangoDB GmbH, Cologne, Germany
///
/// @author Jan Steemann
////////////////////////////////////////////////////////////////////////////////
#include "v8-ttl.h"
#include "Basics/Result.h"
#include "RestServer/TtlFeature.h"
#include "V8/v8-globals.h"
#include "V8/v8-utils.h"
#include "V8/v8-vpack.h"
#include "VocBase/Methods/Ttl.h"
#include <velocypack/Builder.h>
#include <velocypack/velocypack-aliases.h>
using namespace arangodb;
/// @brief returns the TTL properties
static void JS_TtlProperties(v8::FunctionCallbackInfo<v8::Value> const& args) {
TRI_V8_TRY_CATCH_BEGIN(isolate);
v8::HandleScope scope(isolate);
if (args.Length() > 1) {
TRI_V8_THROW_EXCEPTION_USAGE("properties(<object>)");
}
VPackBuilder builder;
Result result;
auto& server = application_features::ApplicationServer::server();
if (args.Length() == 0) {
// get properties
result = methods::Ttl::getProperties(server.getFeature<TtlFeature>(), builder);
} else {
// set properties
VPackBuilder properties;
int res = TRI_V8ToVPack(isolate, properties, args[0], false);
if (res != TRI_ERROR_NO_ERROR) {
TRI_V8_THROW_EXCEPTION(res);
}
result = methods::Ttl::setProperties(server.getFeature<TtlFeature>(),
properties.slice(), builder);
}
if (result.fail()) {
THROW_ARANGO_EXCEPTION(result);
}
v8::Handle<v8::Value> obj = TRI_VPackToV8(isolate, builder.slice());
TRI_V8_RETURN(obj);
TRI_V8_TRY_CATCH_END
}
/// @brief returns the TTL statistics
static void JS_TtlStatistics(v8::FunctionCallbackInfo<v8::Value> const& args) {
TRI_V8_TRY_CATCH_BEGIN(isolate);
v8::HandleScope scope(isolate);
VPackBuilder builder;
auto& server = application_features::ApplicationServer::server();
Result result = methods::Ttl::getStatistics(server.getFeature<TtlFeature>(), builder);
if (result.fail()) {
THROW_ARANGO_EXCEPTION(result);
}
v8::Handle<v8::Value> obj = TRI_VPackToV8(isolate, builder.slice());
TRI_V8_RETURN(obj);
TRI_V8_TRY_CATCH_END
}
/// @brief initializes the ttl functions
void TRI_InitV8Ttl(v8::Isolate* isolate) {
v8::HandleScope scope(isolate);
TRI_AddGlobalFunctionVocbase(isolate,
TRI_V8_ASCII_STRING(isolate,
"SYS_TTL_STATISTICS"),
JS_TtlStatistics);
TRI_AddGlobalFunctionVocbase(isolate,
TRI_V8_ASCII_STRING(isolate,
"SYS_TTL_PROPERTIES"),
JS_TtlProperties);
}
|
;
; Copy a buffer of 8 graphics rows to the zx printer
;
; Stefano Bodrato, 2018
;
;
; $Id: zx_print_buf.asm $
;
SECTION code_clib
PUBLIC zx_print_buf
PUBLIC _zx_print_buf
PUBLIC zx_print_row
PUBLIC _zx_print_row
EXTERN zx_fast
EXTERN zx_slow
.zx_print_buf
._zx_print_buf
; FASTCALL: HL holds the buffer location
push hl
call zx_fast
pop hl
LD B,8
jr eightrows
.zx_print_row
._zx_print_row
; FASTCALL: HL holds the buffer location
push hl
call zx_fast
pop hl
ld B,1
.eightrows
XOR A ; SET REGISTER BITS 0-7 TO ZERO
OUT ($FB),A ; START PRINTER (BIT 2=0)
.LOOP1
IN A,($FB) ; GET PRINTER STATUS BYTE
RLA ; ROTATE BIT 7 (LF BUSY) TO C FLAG
JR NC,LOOP1 ; LOOP IF LINEFEED IS BUSY
PUSH BC ; SAVE ROW COUNT
.L0EF4 LD A,B ; row counter
CP $03 ; cleverly prepare a printer control mask
SBC A,A ; to slow printer for the last two pixel lines
AND $02 ; keep bit 1
OUT ($FB),A ; bit 2 is reset, turn on the zx printer
LD D,A ; save the printer control mask
;; COPY-L-1
.L0EFD ;CALL L1F54 ; routine
.L1F54 LD A,$7F ; BREAK-KEY
IN A,($FE) ;
RRA ;
jr nc,copy_exit
;; COPY-CONT
.L0F0C IN A,($FB) ; read printer port
ADD A,A ; test bit 6 and 7
JP M,copy_exit ; return if no printer or hw error
JR NC,L0F0C ; if bit 7 is reset (LF BUSY), then wait
LD C,32 ; 32 bytes line
;; COPY-BYTES
.L0F14 LD E,(HL) ; get byte data
INC HL
LD B,8 ; 8 bit
;; COPY-BITS
.L0F18 RL D ; mix the printer control mask
RL E ; and the data byte
RR D ; to alter the stylus speed
;; COPY-WAIT
.L0F1E IN A,($FB) ; read the printer port
RRA ; test for alignment signal from encoder.
JR NC,L0F1E ; loop until not present to COPY-WAIT
LD A,D ; control byte to A
OUT ($FB),A ; and output to printer por
DJNZ L0F18 ; loop for all eight bits to COPY-BITS
DEC C ; loop for all the 32 bytes in the current line
JR NZ,L0F14 ; to COPY-BYTES
POP BC
DJNZ LOOP1 ; REPEAT 8 TIMES
PUSH BC ; BALANCE STACK
.copy_exit
POP BC ; BALANCE STACK
LD A,4 ; BIT 2 IS PRINTER ON/OFF BIT
OUT ($FB),A ; TURN OFF PRINTER
JP zx_slow
|
cm_ad_submenu_presets:
dw cm_ad_presets_goto_escape
dw cm_ad_presets_goto_eastern
dw cm_ad_presets_goto_pod
dw cm_ad_presets_goto_hera
dw cm_ad_presets_goto_thieves
dw cm_ad_presets_goto_skull
dw cm_ad_presets_goto_desert
dw cm_ad_presets_goto_mire
dw cm_ad_presets_goto_swamp
dw cm_ad_presets_goto_ice
dw cm_ad_presets_goto_trock
dw cm_ad_presets_goto_gtower
dw cm_ad_presets_goto_atower
dw cm_ad_presets_goto_ganon
dw cm_ad_presets_goto_boss
dw #$0000
%cm_header("PRESETS")
; HYRULE CASTLE
cm_ad_presets_goto_escape:
%cm_submenu("Hyrule Castle", cm_ad_presets_escape)
cm_ad_presets_escape:
dw cm_ad_esc_links_bed
dw cm_ad_esc_courtyard
dw cm_ad_esc_entrance
dw cm_ad_esc_1st_key_guard
dw cm_ad_esc_stealth_room
dw cm_ad_esc_2nd_key_guard
dw cm_ad_esc_ball_n_chains
dw cm_ad_esc_backtracking
dw cm_ad_esc_key_guard_revisit
dw cm_ad_esc_throne_room
dw cm_ad_esc_snake_avoidance
dw cm_ad_esc_sewer_rooms
dw cm_ad_esc_keyrat
dw cm_ad_esc_last_two
dw #$0000
%cm_header("HYRULE CASTLE")
cm_ad_esc_links_bed:
%cm_preset("Link's Bed", preset_ad_esc_links_bed)
cm_ad_esc_courtyard:
%cm_preset("Courtyard", preset_ad_esc_courtyard)
cm_ad_esc_entrance:
%cm_preset("Entrance", preset_ad_esc_entrance)
cm_ad_esc_1st_key_guard:
%cm_preset("1st Key Guard", preset_ad_esc_1st_key_guard)
cm_ad_esc_stealth_room:
%cm_preset("Stealth Room", preset_ad_esc_stealth_room)
cm_ad_esc_2nd_key_guard:
%cm_preset("2nd Key Guard", preset_ad_esc_2nd_key_guard)
cm_ad_esc_ball_n_chains:
%cm_preset("Ball 'n Chains", preset_ad_esc_ball_n_chains)
cm_ad_esc_backtracking:
%cm_preset("Backtracking", preset_ad_esc_backtracking)
cm_ad_esc_key_guard_revisit:
%cm_preset("Key Guard Revisit", preset_ad_esc_key_guard_revisit)
cm_ad_esc_throne_room:
%cm_preset("Throne Room", preset_ad_esc_throne_room)
cm_ad_esc_snake_avoidance:
%cm_preset("Snake Avoidance", preset_ad_esc_snake_avoidance)
cm_ad_esc_sewer_rooms:
%cm_preset("Sewer Rooms", preset_ad_esc_sewer_rooms)
cm_ad_esc_keyrat:
%cm_preset("Keyrat", preset_ad_esc_keyrat)
cm_ad_esc_last_two:
%cm_preset("Last Two", preset_ad_esc_last_two)
; EASTERN
cm_ad_presets_goto_eastern:
%cm_submenu("Eastern Palace", cm_ad_presets_eastern)
cm_ad_presets_eastern:
dw cm_ad_east_before_cutscene
dw cm_ad_east_links_house
dw cm_ad_east_ep_overworld
dw cm_ad_east_entrance
dw cm_ad_east_stalfos_room
dw cm_ad_east_big_chest_room_1
dw cm_ad_east_dark_key_room
dw cm_ad_east_big_key_dmg_boost
dw cm_ad_east_big_chest_room_2
dw cm_ad_east_gifted_with_greenies
dw cm_ad_east_pot_room
dw cm_ad_east_zeldagamer_room
dw cm_ad_east_armos
dw #$0000
%cm_header("EASTERN")
cm_ad_east_before_cutscene:
%cm_preset("Before Cutscene", preset_ad_east_before_cutscene)
cm_ad_east_links_house:
%cm_preset("Link's House", preset_ad_east_links_house)
cm_ad_east_ep_overworld:
%cm_preset("EP Overworld", preset_ad_east_ep_overworld)
cm_ad_east_entrance:
%cm_preset("Entrance", preset_ad_east_entrance)
cm_ad_east_stalfos_room:
%cm_preset("Stalfos Room", preset_ad_east_stalfos_room)
cm_ad_east_big_chest_room_1:
%cm_preset("Big Chest Room 1", preset_ad_east_big_chest_room_1)
cm_ad_east_dark_key_room:
%cm_preset("Dark Key Room", preset_ad_east_dark_key_room)
cm_ad_east_big_key_dmg_boost:
%cm_preset("Big Key DMG Boost", preset_ad_east_big_key_dmg_boost)
cm_ad_east_big_chest_room_2:
%cm_preset("Big Chest Room 2", preset_ad_east_big_chest_room_2)
cm_ad_east_gifted_with_greenies:
%cm_preset("Gifted with Greenies", preset_ad_east_gifted_with_greenies)
cm_ad_east_pot_room:
%cm_preset("Pot Room", preset_ad_east_pot_room)
cm_ad_east_zeldagamer_room:
%cm_preset("Zeldagamer Room", preset_ad_east_zeldagamer_room)
cm_ad_east_armos:
%cm_preset("Armos", preset_ad_east_armos)
; PALACE OF DARKNESS
cm_ad_presets_goto_pod:
%cm_submenu("Palace of Darness", cm_ad_presets_pod)
cm_ad_presets_pod:
dw cm_ad_pod_outside_ep
dw cm_ad_pod_sanctuary
dw cm_ad_pod_dma
dw cm_ad_pod_death_mountain
dw cm_ad_pod_after_mirror
dw cm_ad_pod_kiki_skip
dw cm_ad_pod_dungeon_reload
dw cm_ad_pod_main_hub_bk
dw cm_ad_pod_main_hub_hammerjump
dw cm_ad_pod_hammerjump
dw cm_ad_pod_archery_contest
dw cm_ad_pod_mimics
dw cm_ad_pod_statue
dw cm_ad_pod_basement
dw cm_ad_pod_turtle_room
dw cm_ad_pod_helma
dw #$0000
%cm_header("PALACE OF DARKNESS")
cm_ad_pod_outside_ep:
%cm_preset("Outside EP", preset_ad_pod_outside_ep)
cm_ad_pod_sanctuary:
%cm_preset("Sanctuary", preset_ad_pod_sanctuary)
cm_ad_pod_dma:
%cm_preset("DMA", preset_ad_pod_dma)
cm_ad_pod_death_mountain:
%cm_preset("Death Mountain", preset_ad_pod_death_mountain)
cm_ad_pod_after_mirror:
%cm_preset("After Mirror", preset_ad_pod_after_mirror)
cm_ad_pod_kiki_skip:
%cm_preset("Kiki Skip", preset_ad_pod_kiki_skip)
cm_ad_pod_dungeon_reload:
%cm_preset("Dungeon Reload", preset_ad_pod_dungeon_reload)
cm_ad_pod_main_hub_bk:
%cm_preset("Main Hub (bk)", preset_ad_pod_main_hub_bk)
cm_ad_pod_main_hub_hammerjump:
%cm_preset("Main Hub (hammerjump)", preset_ad_pod_main_hub_hammerjump)
cm_ad_pod_hammerjump:
%cm_preset("Hammerjump", preset_ad_pod_hammerjump)
cm_ad_pod_archery_contest:
%cm_preset("Archery Contest", preset_ad_pod_archery_contest)
cm_ad_pod_mimics:
%cm_preset("Mimics", preset_ad_pod_mimics)
cm_ad_pod_statue:
%cm_preset("Statue", preset_ad_pod_statue)
cm_ad_pod_basement:
%cm_preset("Basement", preset_ad_pod_basement)
cm_ad_pod_turtle_room:
%cm_preset("Turtle Room", preset_ad_pod_turtle_room)
cm_ad_pod_helma:
%cm_preset("Helma", preset_ad_pod_helma)
; HERA TOWER
cm_ad_presets_goto_hera:
%cm_submenu("Hera Tower", cm_ad_presets_hera)
cm_ad_presets_hera:
dw cm_ad_hera_outside_pod
dw cm_ad_hera_old_man_cave
dw cm_ad_hera_entrance
dw cm_ad_hera_tile_room
dw cm_ad_hera_torches
dw cm_ad_hera_beetles
dw cm_ad_hera_petting_zoo
dw cm_ad_hera_moldorm
dw #$0000
%cm_header("HERA TOWER")
cm_ad_hera_outside_pod:
%cm_preset("Outside PoD", preset_ad_hera_outside_pod)
cm_ad_hera_old_man_cave:
%cm_preset("Old Man Cave", preset_ad_hera_old_man_cave)
cm_ad_hera_entrance:
%cm_preset("Entrance", preset_ad_hera_entrance)
cm_ad_hera_tile_room:
%cm_preset("Tile Room", preset_ad_hera_tile_room)
cm_ad_hera_torches:
%cm_preset("Torches", preset_ad_hera_torches)
cm_ad_hera_beetles:
%cm_preset("Beetles", preset_ad_hera_beetles)
cm_ad_hera_petting_zoo:
%cm_preset("Petting Zoo", preset_ad_hera_petting_zoo)
cm_ad_hera_moldorm:
%cm_preset("Moldorm", preset_ad_hera_moldorm)
; THIEVES TOWN
cm_ad_presets_goto_thieves:
%cm_submenu("Thieves' Town", cm_ad_presets_thieves)
cm_ad_presets_thieves:
dw cm_ad_thieves_outside_hera
dw cm_ad_thieves_dmd
dw cm_ad_thieves_entrance
dw cm_ad_thieves_after_big_key
dw cm_ad_thieves_stalfos_hallway
dw cm_ad_thieves_conveyor_gibos
dw cm_ad_thieves_hellway
dw cm_ad_thieves_bomb_floor
dw cm_ad_thieves_backtracking
dw cm_ad_thieves_basement
dw cm_ad_thieves_prison
dw cm_ad_thieves_backtracking_2
dw cm_ad_thieves_pot_hammerdash
dw cm_ad_thieves_blind
dw #$0000
%cm_header("THIEVES TOWN")
cm_ad_thieves_outside_hera:
%cm_preset("Outside Hera", preset_ad_thieves_outside_hera)
cm_ad_thieves_dmd:
%cm_preset("DMD", preset_ad_thieves_dmd)
cm_ad_thieves_entrance:
%cm_preset("Entrance", preset_ad_thieves_entrance)
cm_ad_thieves_after_big_key:
%cm_preset("After Big Key", preset_ad_thieves_after_big_key)
cm_ad_thieves_stalfos_hallway:
%cm_preset("Stalfos Hallway", preset_ad_thieves_stalfos_hallway)
cm_ad_thieves_conveyor_gibos:
%cm_preset("Conveyor Gibos", preset_ad_thieves_conveyor_gibos)
cm_ad_thieves_hellway:
%cm_preset("Hellway", preset_ad_thieves_hellway)
cm_ad_thieves_bomb_floor:
%cm_preset("Bomb Floor", preset_ad_thieves_bomb_floor)
cm_ad_thieves_backtracking:
%cm_preset("Backtracking", preset_ad_thieves_backtracking)
cm_ad_thieves_basement:
%cm_preset("Basement", preset_ad_thieves_basement)
cm_ad_thieves_prison:
%cm_preset("Prison", preset_ad_thieves_prison)
cm_ad_thieves_backtracking_2:
%cm_preset("Backtracking", preset_ad_thieves_backtracking_2)
cm_ad_thieves_pot_hammerdash:
%cm_preset("Pot Hammerdash", preset_ad_thieves_pot_hammerdash)
cm_ad_thieves_blind:
%cm_preset("Blind", preset_ad_thieves_blind)
; SKULL WOODS
cm_ad_presets_goto_skull:
%cm_submenu("Skull Woods", cm_ad_presets_skull)
cm_ad_presets_skull:
dw cm_ad_skull_outside_thieves
dw cm_ad_skull_cursed_dwarf
dw cm_ad_skull_getting_tempered
dw cm_ad_skull_fencedash
dw cm_ad_skull_dash_to_skull_woods
dw cm_ad_skull_mummy_room
dw cm_ad_skull_bomb_jump
dw cm_ad_skull_key_pot
dw cm_ad_skull_skull_entrance
dw cm_ad_skull_mummy_hellway
dw cm_ad_skull_mummy_key
dw cm_ad_skull_mothula
dw #$0000
%cm_header("SKULL WOODS")
cm_ad_skull_outside_thieves:
%cm_preset("Outside Thieves", preset_ad_skull_outside_thieves)
cm_ad_skull_cursed_dwarf:
%cm_preset("Cursed Dwarf", preset_ad_skull_cursed_dwarf)
cm_ad_skull_getting_tempered:
%cm_preset("Getting Tempered", preset_ad_skull_getting_tempered)
cm_ad_skull_fencedash:
%cm_preset("Fencedash", preset_ad_skull_fencedash)
cm_ad_skull_dash_to_skull_woods:
%cm_preset("Dash to Skull Woods", preset_ad_skull_dash_to_skull_woods)
cm_ad_skull_mummy_room:
%cm_preset("Mummy Room", preset_ad_skull_mummy_room)
cm_ad_skull_bomb_jump:
%cm_preset("Bomb Jump", preset_ad_skull_bomb_jump)
cm_ad_skull_key_pot:
%cm_preset("Key Pot", preset_ad_skull_key_pot)
cm_ad_skull_skull_entrance:
%cm_preset("Skull Entrance", preset_ad_skull_skull_entrance)
cm_ad_skull_mummy_hellway:
%cm_preset("Mummy Hellway", preset_ad_skull_mummy_hellway)
cm_ad_skull_mummy_key:
%cm_preset("Mummy Key", preset_ad_skull_mummy_key)
cm_ad_skull_mothula:
%cm_preset("Mothula", preset_ad_skull_mothula)
; DESERT PALACE
cm_ad_presets_goto_desert:
%cm_submenu("Desert Palace", cm_ad_presets_desert)
cm_ad_presets_desert:
dw cm_ad_desert_outside_skull
dw cm_ad_desert_ether
dw cm_ad_desert_bridge_hammerdash
dw cm_ad_desert_zora_dmd
dw cm_ad_desert_links_house
dw cm_ad_desert_swamp_warp
dw cm_ad_desert_fluteless_mire
dw cm_ad_desert_desert_entrance
dw cm_ad_desert_torch_key
dw cm_ad_desert_pre_cannonballs
dw cm_ad_desert_desert_2_spinspeed
dw cm_ad_desert_torches
dw cm_ad_desert_lanmolas
dw #$0000
%cm_header("DESERT PALACE")
cm_ad_desert_outside_skull:
%cm_preset("Outside Skull", preset_ad_desert_outside_skull)
cm_ad_desert_ether:
%cm_preset("Ether", preset_ad_desert_ether)
cm_ad_desert_bridge_hammerdash:
%cm_preset("Bridge Hammerdash", preset_ad_desert_bridge_hammerdash)
cm_ad_desert_zora_dmd:
%cm_preset("Zora DMD", preset_ad_desert_zora_dmd)
cm_ad_desert_links_house:
%cm_preset("Link's House", preset_ad_desert_links_house)
cm_ad_desert_swamp_warp:
%cm_preset("Swamp Warp", preset_ad_desert_swamp_warp)
cm_ad_desert_fluteless_mire:
%cm_preset("Fluteless Mire", preset_ad_desert_fluteless_mire)
cm_ad_desert_desert_entrance:
%cm_preset("Desert Entrance", preset_ad_desert_desert_entrance)
cm_ad_desert_torch_key:
%cm_preset("Torch Key", preset_ad_desert_torch_key)
cm_ad_desert_pre_cannonballs:
%cm_preset("Pre Cannonballs", preset_ad_desert_pre_cannonballs)
cm_ad_desert_desert_2_spinspeed:
%cm_preset("Desert 2 Spinspeed", preset_ad_desert_desert_2_spinspeed)
cm_ad_desert_torches:
%cm_preset("Torches", preset_ad_desert_torches)
cm_ad_desert_lanmolas:
%cm_preset("Lanmolas", preset_ad_desert_lanmolas)
; MISERY MIRE
cm_ad_presets_goto_mire:
%cm_submenu("Misery Mire", cm_ad_presets_mire)
cm_ad_presets_mire:
dw cm_ad_mire_outside_desert
dw cm_ad_mire_entrance
dw cm_ad_mire_mire_2
dw cm_ad_mire_main_hub
dw cm_ad_mire_spike_key
dw cm_ad_mire_beat_the_fireball
dw cm_ad_mire_bari_switch
dw cm_ad_mire_sluggulas
dw cm_ad_mire_torches
dw cm_ad_mire_backtracking
dw cm_ad_mire_mire_to_hera_clip
dw cm_ad_mire_hera_to_swamp_clip
dw cm_ad_mire_mire_2_2
dw cm_ad_mire_big_chest_room
dw cm_ad_mire_main_hub_post_cane
dw cm_ad_mire_bridge_room
dw cm_ad_mire_spooky_action
dw cm_ad_mire_vitreous
dw #$0000
%cm_header("MISERY MIRE")
cm_ad_mire_outside_desert:
%cm_preset("Outside Desert", preset_ad_mire_outside_desert)
cm_ad_mire_entrance:
%cm_preset("Entrance", preset_ad_mire_entrance)
cm_ad_mire_mire_2:
%cm_preset("Mire 2", preset_ad_mire_mire_2)
cm_ad_mire_main_hub:
%cm_preset("Main Hub", preset_ad_mire_main_hub)
cm_ad_mire_spike_key:
%cm_preset("Spike Key", preset_ad_mire_spike_key)
cm_ad_mire_beat_the_fireball:
%cm_preset("Beat the Fireball", preset_ad_mire_beat_the_fireball)
cm_ad_mire_bari_switch:
%cm_preset("Bari Switch", preset_ad_mire_bari_switch)
cm_ad_mire_sluggulas:
%cm_preset("Sluggulas", preset_ad_mire_sluggulas)
cm_ad_mire_torches:
%cm_preset("Torches", preset_ad_mire_torches)
cm_ad_mire_backtracking:
%cm_preset("Backtracking", preset_ad_mire_backtracking)
cm_ad_mire_mire_to_hera_clip:
%cm_preset("Mire to Hera Clip", preset_ad_mire_mire_to_hera_clip)
cm_ad_mire_hera_to_swamp_clip:
%cm_preset("Hera to Swamp Clip", preset_ad_mire_hera_to_swamp_clip)
cm_ad_mire_mire_2_2:
%cm_preset("Mire 2-2", preset_ad_mire_mire_2_2)
cm_ad_mire_big_chest_room:
%cm_preset("Big Chest Room", preset_ad_mire_big_chest_room)
cm_ad_mire_main_hub_post_cane:
%cm_preset("Main Hub (post Cane)", preset_ad_mire_main_hub_post_cane)
cm_ad_mire_bridge_room:
%cm_preset("Bridge Room", preset_ad_mire_bridge_room)
cm_ad_mire_spooky_action:
%cm_preset("Spooky Action", preset_ad_mire_spooky_action)
cm_ad_mire_vitreous:
%cm_preset("Vitreous", preset_ad_mire_vitreous)
; SWAMP PALACE
cm_ad_presets_goto_swamp:
%cm_submenu("Swamp Palace", cm_ad_presets_swamp)
cm_ad_presets_swamp:
dw cm_ad_swamp_outside_mire
dw cm_ad_swamp_antifairy_room
dw cm_ad_swamp_entrance
dw cm_ad_swamp_first_key_pot
dw cm_ad_swamp_main_hub
dw cm_ad_swamp_hookdash
dw cm_ad_swamp_restock_room
dw cm_ad_swamp_phelps_way
dw cm_ad_swamp_arrghus
dw #$0000
%cm_header("SWAMP PALACE")
cm_ad_swamp_outside_mire:
%cm_preset("Outside Mire", preset_ad_swamp_outside_mire)
cm_ad_swamp_antifairy_room:
%cm_preset("Antifairy Room", preset_ad_swamp_antifairy_room)
cm_ad_swamp_entrance:
%cm_preset("Entrance", preset_ad_swamp_entrance)
cm_ad_swamp_first_key_pot:
%cm_preset("First Key Pot", preset_ad_swamp_first_key_pot)
cm_ad_swamp_main_hub:
%cm_preset("Main Hub", preset_ad_swamp_main_hub)
cm_ad_swamp_hookdash:
%cm_preset("Hookdash", preset_ad_swamp_hookdash)
cm_ad_swamp_restock_room:
%cm_preset("Restock Room", preset_ad_swamp_restock_room)
cm_ad_swamp_phelps_way:
%cm_preset("Phelps Way", preset_ad_swamp_phelps_way)
cm_ad_swamp_arrghus:
%cm_preset("Arrghus", preset_ad_swamp_arrghus)
; ICE PALACE
cm_ad_presets_goto_ice:
%cm_submenu("Ice Palace", cm_ad_presets_ice)
cm_ad_presets_ice:
dw cm_ad_ice_outside_swamp
dw cm_ad_ice_entrance
dw cm_ad_ice_ice_conveyor
dw cm_ad_ice_ipbj
dw cm_ad_ice_penguin_lineup_room
dw cm_ad_ice_lonely_firebar
dw cm_ad_ice_last_two_screens
dw cm_ad_ice_kholdstare
dw #$0000
%cm_header("ICE PALACE")
cm_ad_ice_outside_swamp:
%cm_preset("Outside Swamp", preset_ad_ice_outside_swamp)
cm_ad_ice_entrance:
%cm_preset("Entrance", preset_ad_ice_entrance)
cm_ad_ice_ice_conveyor:
%cm_preset("Ice Conveyor", preset_ad_ice_ice_conveyor)
cm_ad_ice_ipbj:
%cm_preset("IPBJ", preset_ad_ice_ipbj)
cm_ad_ice_penguin_lineup_room:
%cm_preset("Penguin Lineup Room", preset_ad_ice_penguin_lineup_room)
cm_ad_ice_lonely_firebar:
%cm_preset("Lonely Firebar", preset_ad_ice_lonely_firebar)
cm_ad_ice_last_two_screens:
%cm_preset("Last Two Screens", preset_ad_ice_last_two_screens)
cm_ad_ice_kholdstare:
%cm_preset("Kholdstare", preset_ad_ice_kholdstare)
; TURTLE ROCK
cm_ad_presets_goto_trock:
%cm_submenu("Turtle Rock", cm_ad_presets_trock)
cm_ad_presets_trock:
dw cm_ad_trock_outside_ice
dw cm_ad_trock_old_man_cave
dw cm_ad_trock_tr_climb
dw cm_ad_trock_laser_entrance
dw cm_ad_trock_crystal_roller
dw cm_ad_trock_pokey_1
dw cm_ad_trock_laser_entrance_2
dw cm_ad_trock_switch_maze
dw cm_ad_trock_trinexx
dw #$0000
%cm_header("TURTLE ROCK")
cm_ad_trock_outside_ice:
%cm_preset("Outside Ice", preset_ad_trock_outside_ice)
cm_ad_trock_old_man_cave:
%cm_preset("Old Man Cave", preset_ad_trock_old_man_cave)
cm_ad_trock_tr_climb:
%cm_preset("TR Climb", preset_ad_trock_tr_climb)
cm_ad_trock_laser_entrance:
%cm_preset("Laser Entrance", preset_ad_trock_laser_entrance)
cm_ad_trock_crystal_roller:
%cm_preset("Crystal Roller", preset_ad_trock_crystal_roller)
cm_ad_trock_pokey_1:
%cm_preset("Pokey 1", preset_ad_trock_pokey_1)
cm_ad_trock_laser_entrance_2:
%cm_preset("Laser Entrance 2", preset_ad_trock_laser_entrance_2)
cm_ad_trock_switch_maze:
%cm_preset("Switch Maze", preset_ad_trock_switch_maze)
cm_ad_trock_trinexx:
%cm_preset("Trinexx", preset_ad_trock_trinexx)
; GANONS TOWER
cm_ad_presets_goto_gtower:
%cm_submenu("Ganon's Tower", cm_ad_presets_gtower)
cm_ad_presets_gtower:
dw cm_ad_gtower_outside_turtle_rock
dw cm_ad_gtower_old_man_cave
dw cm_ad_gtower_entrance
dw cm_ad_gtower_spike_skip
dw cm_ad_gtower_pre_firesnakes_room
dw cm_ad_gtower_bombable_floor
dw cm_ad_gtower_floor_2
dw cm_ad_gtower_mimics_1
dw cm_ad_gtower_spike_pit
dw cm_ad_gtower_gauntlet_1
dw cm_ad_gtower_lanmola_2
dw cm_ad_gtower_wizzrobes_1
dw cm_ad_gtower_wizzrobes_2
dw cm_ad_gtower_torches_1
dw cm_ad_gtower_torches_2
dw cm_ad_gtower_helma_key
dw cm_ad_gtower_bombable_wall
dw cm_ad_gtower_moldorm_2
dw cm_ad_gtower_agahnim_2
dw #$0000
%cm_header("GANONS TOWER")
cm_ad_gtower_outside_turtle_rock:
%cm_preset("Outside Turtle Rock", preset_ad_gtower_outside_turtle_rock)
cm_ad_gtower_old_man_cave:
%cm_preset("Old Man Cave", preset_ad_gtower_old_man_cave)
cm_ad_gtower_entrance:
%cm_preset("Entrance", preset_ad_gtower_entrance)
cm_ad_gtower_spike_skip:
%cm_preset("Spike Skip", preset_ad_gtower_spike_skip)
cm_ad_gtower_pre_firesnakes_room:
%cm_preset("Pre Firesnakes Room", preset_ad_gtower_pre_firesnakes_room)
cm_ad_gtower_bombable_floor:
%cm_preset("Bombable Floor", preset_ad_gtower_bombable_floor)
cm_ad_gtower_floor_2:
%cm_preset("Floor 2", preset_ad_gtower_floor_2)
cm_ad_gtower_mimics_1:
%cm_preset("Mimics 1", preset_ad_gtower_mimics_1)
cm_ad_gtower_spike_pit:
%cm_preset("Spike Pit", preset_ad_gtower_spike_pit)
cm_ad_gtower_gauntlet_1:
%cm_preset("Gauntlet 1", preset_ad_gtower_gauntlet_1)
cm_ad_gtower_lanmola_2:
%cm_preset("Lanmola 2", preset_ad_gtower_lanmola_2)
cm_ad_gtower_wizzrobes_1:
%cm_preset("Wizzrobes 1", preset_ad_gtower_wizzrobes_1)
cm_ad_gtower_wizzrobes_2:
%cm_preset("Wizzrobes 2", preset_ad_gtower_wizzrobes_2)
cm_ad_gtower_torches_1:
%cm_preset("Torches 1", preset_ad_gtower_torches_1)
cm_ad_gtower_torches_2:
%cm_preset("Torches 2", preset_ad_gtower_torches_2)
cm_ad_gtower_helma_key:
%cm_preset("Helma Key", preset_ad_gtower_helma_key)
cm_ad_gtower_bombable_wall:
%cm_preset("Bombable Wall", preset_ad_gtower_bombable_wall)
cm_ad_gtower_moldorm_2:
%cm_preset("Moldorm 2", preset_ad_gtower_moldorm_2)
cm_ad_gtower_agahnim_2:
%cm_preset("Agahnim 2", preset_ad_gtower_agahnim_2)
; AGAHNIMS TOWER
cm_ad_presets_goto_atower:
%cm_submenu("Agahnim's Tower", cm_ad_presets_atower)
cm_ad_presets_atower:
dw cm_ad_atower_pyramid
dw cm_ad_atower_gold_knights
dw cm_ad_atower_dark_room_of_despair
dw cm_ad_atower_dark_room_of_melancholy
dw cm_ad_atower_spear_guards
dw cm_ad_atower_circle_of_pots
dw cm_ad_atower_pit_room
dw cm_ad_atower_agahnim
dw #$0000
%cm_header("AGAHNIMS TOWER")
cm_ad_atower_pyramid:
%cm_preset("Pyramid", preset_ad_atower_pyramid)
cm_ad_atower_gold_knights:
%cm_preset("Gold Knights", preset_ad_atower_gold_knights)
cm_ad_atower_dark_room_of_despair:
%cm_preset("Dark Room of Despair", preset_ad_atower_dark_room_of_despair)
cm_ad_atower_dark_room_of_melancholy:
%cm_preset("Dark Room of Melancholy", preset_ad_atower_dark_room_of_melancholy)
cm_ad_atower_spear_guards:
%cm_preset("Spear Guards", preset_ad_atower_spear_guards)
cm_ad_atower_circle_of_pots:
%cm_preset("Circle of Pots", preset_ad_atower_circle_of_pots)
cm_ad_atower_pit_room:
%cm_preset("Pit Room", preset_ad_atower_pit_room)
cm_ad_atower_agahnim:
%cm_preset("Agahnim", preset_ad_atower_agahnim)
; GANON
cm_ad_presets_goto_ganon:
%cm_submenu("Ganon", cm_ad_presets_ganon)
cm_ad_presets_ganon:
dw cm_ad_ganon_pyramid
dw #$0000
%cm_header("GANON")
cm_ad_ganon_pyramid:
%cm_preset("Pyramid", preset_ad_ganon_pyramid)
; BOSSES
cm_ad_presets_goto_boss:
%cm_submenu("Bosses", cm_ad_presets_boss)
cm_ad_presets_boss:
dw cm_ad_east_armos
dw cm_ad_pod_helma
dw cm_ad_hera_moldorm
dw cm_ad_thieves_blind
dw cm_ad_skull_mothula
dw cm_ad_desert_lanmolas
dw cm_ad_mire_vitreous
dw cm_ad_swamp_arrghus
dw cm_ad_ice_kholdstare
dw cm_ad_trock_trinexx
dw cm_ad_gtower_agahnim_2
dw cm_ad_atower_agahnim
dw cm_ad_ganon_pyramid
dw #$0000
%cm_header("BOSSES")
|
// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/chromeos/file_manager/url_util.h"
#include <memory>
#include "ash/constants/ash_features.h"
#include "base/files/file_path.h"
#include "base/json/json_reader.h"
#include "base/json/json_writer.h"
#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
#include "base/values.h"
#include "extensions/common/constants.h"
#include "net/base/escape.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace file_manager {
namespace util {
namespace {
// Parse a JSON query string into a base::Value.
base::Value ParseJsonQueryString(const std::string& query) {
const std::string json = net::UnescapeBinaryURLComponent(query);
std::unique_ptr<base::Value> value = base::JSONReader::ReadDeprecated(json);
return value ? std::move(*value) : base::Value();
}
// Pretty print the JSON escaped in the query string.
std::string PrettyPrintEscapedJson(const std::string& query) {
std::string pretty_json;
base::JSONWriter::WriteWithOptions(ParseJsonQueryString(query),
base::JSONWriter::OPTIONS_PRETTY_PRINT,
&pretty_json);
return pretty_json;
}
TEST(FileManagerUrlUtilTest, GetFileManagerMainPageUrl) {
if (base::FeatureList::IsEnabled(chromeos::features::kFilesJsModules)) {
EXPECT_EQ(
"chrome-extension://hhaomjibdihmijegdhdafkllkbggdgoj/main_modules.html",
GetFileManagerMainPageUrl().spec());
} else {
EXPECT_EQ("chrome-extension://hhaomjibdihmijegdhdafkllkbggdgoj/main.html",
GetFileManagerMainPageUrl().spec());
}
}
TEST(FileManagerUrlUtilTest, GetFileManagerMainPageUrlWithParams_NoFileTypes) {
const GURL url = GetFileManagerMainPageUrlWithParams(
ui::SelectFileDialog::SELECT_OPEN_FILE, base::UTF8ToUTF16("some title"),
GURL("filesystem:chrome-extension://abc/Downloads/"),
GURL("filesystem:chrome-extension://abc/Downloads/foo.txt"), "foo.txt",
nullptr, // No file types
0, // Hence no file type index.
"", // search_query
false // show_android_picker_apps
);
EXPECT_EQ(extensions::kExtensionScheme, url.scheme());
EXPECT_EQ("hhaomjibdihmijegdhdafkllkbggdgoj", url.host());
if (base::FeatureList::IsEnabled(chromeos::features::kFilesJsModules)) {
EXPECT_EQ("/main_modules.html", url.path());
} else {
EXPECT_EQ("/main.html", url.path());
}
// Confirm that "%20" is used instead of "+" in the query.
EXPECT_TRUE(url.query().find("+") == std::string::npos);
EXPECT_TRUE(url.query().find("%20") != std::string::npos);
// With DriveFS, Drive is always allowed where native paths are.
EXPECT_EQ(base::StringPrintf(
"{\n"
" \"allowedPaths\": \"nativePath\",\n"
" \"currentDirectoryURL\": "
"\"filesystem:chrome-extension://abc/Downloads/\",\n"
" \"searchQuery\": \"\",\n"
" \"selectionURL\": "
"\"filesystem:chrome-extension://abc/Downloads/foo.txt\",\n"
" \"showAndroidPickerApps\": false,\n"
" \"targetName\": \"foo.txt\",\n"
" \"title\": \"some title\",\n"
" \"type\": \"open-file\"\n"
"}\n"),
PrettyPrintEscapedJson(url.query()));
}
TEST(FileManagerUrlUtilTest,
GetFileManagerMainPageUrlWithParams_WithFileTypes) {
// Create a FileTypeInfo which looks like:
// extensions: [["htm", "html"], ["txt"]]
// descriptions: ["HTML", "TEXT"]
ui::SelectFileDialog::FileTypeInfo file_types;
file_types.extensions.emplace_back();
file_types.extensions[0].push_back(FILE_PATH_LITERAL("htm"));
file_types.extensions[0].push_back(FILE_PATH_LITERAL("html"));
file_types.extensions.emplace_back();
file_types.extensions[1].push_back(FILE_PATH_LITERAL("txt"));
file_types.extension_description_overrides.push_back(
base::UTF8ToUTF16("HTML"));
file_types.extension_description_overrides.push_back(
base::UTF8ToUTF16("TEXT"));
// "shouldReturnLocalPath" will be false if drive is supported.
file_types.allowed_paths = ui::SelectFileDialog::FileTypeInfo::ANY_PATH;
const GURL url = GetFileManagerMainPageUrlWithParams(
ui::SelectFileDialog::SELECT_OPEN_FILE, base::UTF8ToUTF16("some title"),
GURL("filesystem:chrome-extension://abc/Downloads/"),
GURL("filesystem:chrome-extension://abc/Downloads/foo.txt"), "foo.txt",
&file_types,
1, // The file type index is 1-based.
"search query",
true // show_android_picker_apps
);
EXPECT_EQ(extensions::kExtensionScheme, url.scheme());
EXPECT_EQ("hhaomjibdihmijegdhdafkllkbggdgoj", url.host());
if (base::FeatureList::IsEnabled(chromeos::features::kFilesJsModules)) {
EXPECT_EQ("/main_modules.html", url.path());
} else {
EXPECT_EQ("/main.html", url.path());
}
// Confirm that "%20" is used instead of "+" in the query.
EXPECT_TRUE(url.query().find("+") == std::string::npos);
EXPECT_TRUE(url.query().find("%20") != std::string::npos);
// The escaped query is hard to read. Pretty print the escaped JSON.
EXPECT_EQ(
"{\n"
" \"allowedPaths\": \"anyPath\",\n"
" \"currentDirectoryURL\": "
"\"filesystem:chrome-extension://abc/Downloads/\",\n"
" \"includeAllFiles\": false,\n"
" \"searchQuery\": \"search query\",\n"
" \"selectionURL\": "
"\"filesystem:chrome-extension://abc/Downloads/foo.txt\",\n"
" \"showAndroidPickerApps\": true,\n"
" \"targetName\": \"foo.txt\",\n"
" \"title\": \"some title\",\n"
" \"type\": \"open-file\",\n"
" \"typeList\": [ {\n"
" \"description\": \"HTML\",\n"
" \"extensions\": [ \"htm\", \"html\" ],\n"
" \"selected\": true\n"
" }, {\n"
" \"description\": \"TEXT\",\n"
" \"extensions\": [ \"txt\" ],\n"
" \"selected\": false\n"
" } ]\n"
"}\n",
PrettyPrintEscapedJson(url.query()));
}
} // namespace
} // namespace util
} // namespace file_manager
|
#include "EventFilter/RPCRawToDigi/interface/RPCAMC13Record.h"
namespace rpcamc13 {
Header::Header(std::uint64_t const record) : record_(record) {}
Header::Header(unsigned int ufov, unsigned int n_amc, unsigned int orbit_counter) : record_(0x0) {
setFirmwareVersion(ufov);
setNAMC(n_amc);
setOrbitCounter(orbit_counter);
}
Trailer::Trailer(std::uint64_t const record) : record_(record) {}
Trailer::Trailer(std::uint32_t crc, unsigned int block_number, unsigned int event_counter, unsigned int bx_counter)
: record_(0x0) {
setCRC(crc);
setBlockNumber(block_number);
setEventCounter(event_counter);
setBXCounter(bx_counter);
}
AMCHeader::AMCHeader(std::uint64_t const record) : record_(record) {}
AMCHeader::AMCHeader(bool length_correct,
bool last_block,
bool first_block,
bool enabled,
bool present,
bool valid,
bool crc_ok,
unsigned int size,
unsigned int block_number,
unsigned int amc_number,
unsigned int board_id)
: record_(0x0) {
setLengthCorrect(length_correct);
setLastBlock(last_block);
setFirstBlock(first_block);
setEnabled(enabled);
setPresent(present);
setValid(valid);
setCRCOk(crc_ok);
setSize(size);
setBlockNumber(block_number);
setAMCNumber(amc_number);
setBoardId(board_id);
}
AMCPayload::AMCPayload() : valid_(true) {}
} // namespace rpcamc13
|
/*!
* サンプルコード 01(b)
*
* FizzBuzz 問題の結果を標準出力に出力するサンプルコード. @n
*
* 入力となるシーケンスコンテナとして,
* 可変長のシーケンスコンテナ @c std::vector を使用したもの. @n
*
* @file example-01b.c++
* @see fizz_buzzxx::fizz_buzz
*/
#include <fizz-buzz++.h++>
#include <iostream>
#include <iterator>
#include <vector>
/*!
* FizzBuzz 問題の結果を標準出力に出力する
*
* @return プログラムのリターンコード @n
* 常に @c 0 を返却する
*/
auto main() -> int
{
using namespace fizz_buzzxx;
// 1 ~ 100 の整数を格納した可変長のシーケンスコンテナを生成する
std::vector<int> sequence = {};
for (auto index = 0; index < 100; ++index) {
sequence.push_back(index + 1);
}
// FizzBuzz 問題の結果を標準出力に出力する
fizz_buzz(std::begin(sequence), std::end(sequence), [&](const auto value) {
std::cout << value << std::endl;
});
}
|
//===- ARMTargetTransformInfo.cpp - ARM specific TTI ----------------------===//
//
// 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
//
//===----------------------------------------------------------------------===//
#include "ARMTargetTransformInfo.h"
#include "ARMSubtarget.h"
#include "MCTargetDesc/ARMAddressingModes.h"
#include "llvm/ADT/APInt.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/Analysis/LoopInfo.h"
#include "llvm/CodeGen/CostTable.h"
#include "llvm/CodeGen/ISDOpcodes.h"
#include "llvm/CodeGen/ValueTypes.h"
#include "llvm/IR/BasicBlock.h"
#include "llvm/IR/CallSite.h"
#include "llvm/IR/DataLayout.h"
#include "llvm/IR/DerivedTypes.h"
#include "llvm/IR/Instruction.h"
#include "llvm/IR/Instructions.h"
#include "llvm/IR/IntrinsicInst.h"
#include "llvm/IR/PatternMatch.h"
#include "llvm/IR/Type.h"
#include "llvm/MC/SubtargetFeature.h"
#include "llvm/Support/Casting.h"
#include "llvm/Support/MachineValueType.h"
#include "llvm/Target/TargetMachine.h"
#include <algorithm>
#include <cassert>
#include <cstdint>
#include <utility>
using namespace llvm;
#define DEBUG_TYPE "armtti"
static cl::opt<bool> EnableMaskedLoadStores(
"enable-arm-maskedldst", cl::Hidden, cl::init(true),
cl::desc("Enable the generation of masked loads and stores"));
static cl::opt<bool> DisableLowOverheadLoops(
"disable-arm-loloops", cl::Hidden, cl::init(false),
cl::desc("Disable the generation of low-overhead loops"));
extern cl::opt<bool> DisableTailPredication;
extern cl::opt<bool> EnableMaskedGatherScatters;
bool ARMTTIImpl::areInlineCompatible(const Function *Caller,
const Function *Callee) const {
const TargetMachine &TM = getTLI()->getTargetMachine();
const FeatureBitset &CallerBits =
TM.getSubtargetImpl(*Caller)->getFeatureBits();
const FeatureBitset &CalleeBits =
TM.getSubtargetImpl(*Callee)->getFeatureBits();
// To inline a callee, all features not in the whitelist must match exactly.
bool MatchExact = (CallerBits & ~InlineFeatureWhitelist) ==
(CalleeBits & ~InlineFeatureWhitelist);
// For features in the whitelist, the callee's features must be a subset of
// the callers'.
bool MatchSubset = ((CallerBits & CalleeBits) & InlineFeatureWhitelist) ==
(CalleeBits & InlineFeatureWhitelist);
return MatchExact && MatchSubset;
}
bool ARMTTIImpl::shouldFavorBackedgeIndex(const Loop *L) const {
if (L->getHeader()->getParent()->hasOptSize())
return false;
if (ST->hasMVEIntegerOps())
return false;
return ST->isMClass() && ST->isThumb2() && L->getNumBlocks() == 1;
}
bool ARMTTIImpl::shouldFavorPostInc() const {
if (ST->hasMVEIntegerOps())
return true;
return false;
}
int ARMTTIImpl::getIntImmCost(const APInt &Imm, Type *Ty) {
assert(Ty->isIntegerTy());
unsigned Bits = Ty->getPrimitiveSizeInBits();
if (Bits == 0 || Imm.getActiveBits() >= 64)
return 4;
int64_t SImmVal = Imm.getSExtValue();
uint64_t ZImmVal = Imm.getZExtValue();
if (!ST->isThumb()) {
if ((SImmVal >= 0 && SImmVal < 65536) ||
(ARM_AM::getSOImmVal(ZImmVal) != -1) ||
(ARM_AM::getSOImmVal(~ZImmVal) != -1))
return 1;
return ST->hasV6T2Ops() ? 2 : 3;
}
if (ST->isThumb2()) {
if ((SImmVal >= 0 && SImmVal < 65536) ||
(ARM_AM::getT2SOImmVal(ZImmVal) != -1) ||
(ARM_AM::getT2SOImmVal(~ZImmVal) != -1))
return 1;
return ST->hasV6T2Ops() ? 2 : 3;
}
// Thumb1, any i8 imm cost 1.
if (Bits == 8 || (SImmVal >= 0 && SImmVal < 256))
return 1;
if ((~SImmVal < 256) || ARM_AM::isThumbImmShiftedVal(ZImmVal))
return 2;
// Load from constantpool.
return 3;
}
// Constants smaller than 256 fit in the immediate field of
// Thumb1 instructions so we return a zero cost and 1 otherwise.
int ARMTTIImpl::getIntImmCodeSizeCost(unsigned Opcode, unsigned Idx,
const APInt &Imm, Type *Ty) {
if (Imm.isNonNegative() && Imm.getLimitedValue() < 256)
return 0;
return 1;
}
int ARMTTIImpl::getIntImmCostInst(unsigned Opcode, unsigned Idx, const APInt &Imm,
Type *Ty) {
// Division by a constant can be turned into multiplication, but only if we
// know it's constant. So it's not so much that the immediate is cheap (it's
// not), but that the alternative is worse.
// FIXME: this is probably unneeded with GlobalISel.
if ((Opcode == Instruction::SDiv || Opcode == Instruction::UDiv ||
Opcode == Instruction::SRem || Opcode == Instruction::URem) &&
Idx == 1)
return 0;
if (Opcode == Instruction::And) {
// UXTB/UXTH
if (Imm == 255 || Imm == 65535)
return 0;
// Conversion to BIC is free, and means we can use ~Imm instead.
return std::min(getIntImmCost(Imm, Ty), getIntImmCost(~Imm, Ty));
}
if (Opcode == Instruction::Add)
// Conversion to SUB is free, and means we can use -Imm instead.
return std::min(getIntImmCost(Imm, Ty), getIntImmCost(-Imm, Ty));
if (Opcode == Instruction::ICmp && Imm.isNegative() &&
Ty->getIntegerBitWidth() == 32) {
int64_t NegImm = -Imm.getSExtValue();
if (ST->isThumb2() && NegImm < 1<<12)
// icmp X, #-C -> cmn X, #C
return 0;
if (ST->isThumb() && NegImm < 1<<8)
// icmp X, #-C -> adds X, #C
return 0;
}
// xor a, -1 can always be folded to MVN
if (Opcode == Instruction::Xor && Imm.isAllOnesValue())
return 0;
return getIntImmCost(Imm, Ty);
}
int ARMTTIImpl::getCastInstrCost(unsigned Opcode, Type *Dst, Type *Src,
const Instruction *I) {
int ISD = TLI->InstructionOpcodeToISD(Opcode);
assert(ISD && "Invalid opcode");
// Single to/from double precision conversions.
static const CostTblEntry NEONFltDblTbl[] = {
// Vector fptrunc/fpext conversions.
{ ISD::FP_ROUND, MVT::v2f64, 2 },
{ ISD::FP_EXTEND, MVT::v2f32, 2 },
{ ISD::FP_EXTEND, MVT::v4f32, 4 }
};
if (Src->isVectorTy() && ST->hasNEON() && (ISD == ISD::FP_ROUND ||
ISD == ISD::FP_EXTEND)) {
std::pair<int, MVT> LT = TLI->getTypeLegalizationCost(DL, Src);
if (const auto *Entry = CostTableLookup(NEONFltDblTbl, ISD, LT.second))
return LT.first * Entry->Cost;
}
EVT SrcTy = TLI->getValueType(DL, Src);
EVT DstTy = TLI->getValueType(DL, Dst);
if (!SrcTy.isSimple() || !DstTy.isSimple())
return BaseT::getCastInstrCost(Opcode, Dst, Src);
// The extend of a load is free
if (I && isa<LoadInst>(I->getOperand(0))) {
static const TypeConversionCostTblEntry LoadConversionTbl[] = {
{ISD::SIGN_EXTEND, MVT::i32, MVT::i16, 0},
{ISD::ZERO_EXTEND, MVT::i32, MVT::i16, 0},
{ISD::SIGN_EXTEND, MVT::i32, MVT::i8, 0},
{ISD::ZERO_EXTEND, MVT::i32, MVT::i8, 0},
{ISD::SIGN_EXTEND, MVT::i16, MVT::i8, 0},
{ISD::ZERO_EXTEND, MVT::i16, MVT::i8, 0},
{ISD::SIGN_EXTEND, MVT::i64, MVT::i32, 1},
{ISD::ZERO_EXTEND, MVT::i64, MVT::i32, 1},
{ISD::SIGN_EXTEND, MVT::i64, MVT::i16, 1},
{ISD::ZERO_EXTEND, MVT::i64, MVT::i16, 1},
{ISD::SIGN_EXTEND, MVT::i64, MVT::i8, 1},
{ISD::ZERO_EXTEND, MVT::i64, MVT::i8, 1},
};
if (const auto *Entry = ConvertCostTableLookup(
LoadConversionTbl, ISD, DstTy.getSimpleVT(), SrcTy.getSimpleVT()))
return Entry->Cost;
static const TypeConversionCostTblEntry MVELoadConversionTbl[] = {
{ISD::SIGN_EXTEND, MVT::v4i32, MVT::v4i16, 0},
{ISD::ZERO_EXTEND, MVT::v4i32, MVT::v4i16, 0},
{ISD::SIGN_EXTEND, MVT::v4i32, MVT::v4i8, 0},
{ISD::ZERO_EXTEND, MVT::v4i32, MVT::v4i8, 0},
{ISD::SIGN_EXTEND, MVT::v8i16, MVT::v8i8, 0},
{ISD::ZERO_EXTEND, MVT::v8i16, MVT::v8i8, 0},
};
if (SrcTy.isVector() && ST->hasMVEIntegerOps()) {
if (const auto *Entry =
ConvertCostTableLookup(MVELoadConversionTbl, ISD,
DstTy.getSimpleVT(), SrcTy.getSimpleVT()))
return Entry->Cost;
}
}
// Some arithmetic, load and store operations have specific instructions
// to cast up/down their types automatically at no extra cost.
// TODO: Get these tables to know at least what the related operations are.
static const TypeConversionCostTblEntry NEONVectorConversionTbl[] = {
{ ISD::SIGN_EXTEND, MVT::v4i32, MVT::v4i16, 0 },
{ ISD::ZERO_EXTEND, MVT::v4i32, MVT::v4i16, 0 },
{ ISD::SIGN_EXTEND, MVT::v2i64, MVT::v2i32, 1 },
{ ISD::ZERO_EXTEND, MVT::v2i64, MVT::v2i32, 1 },
{ ISD::TRUNCATE, MVT::v4i32, MVT::v4i64, 0 },
{ ISD::TRUNCATE, MVT::v4i16, MVT::v4i32, 1 },
// The number of vmovl instructions for the extension.
{ ISD::SIGN_EXTEND, MVT::v4i64, MVT::v4i16, 3 },
{ ISD::ZERO_EXTEND, MVT::v4i64, MVT::v4i16, 3 },
{ ISD::SIGN_EXTEND, MVT::v8i32, MVT::v8i8, 3 },
{ ISD::ZERO_EXTEND, MVT::v8i32, MVT::v8i8, 3 },
{ ISD::SIGN_EXTEND, MVT::v8i64, MVT::v8i8, 7 },
{ ISD::ZERO_EXTEND, MVT::v8i64, MVT::v8i8, 7 },
{ ISD::SIGN_EXTEND, MVT::v8i64, MVT::v8i16, 6 },
{ ISD::ZERO_EXTEND, MVT::v8i64, MVT::v8i16, 6 },
{ ISD::SIGN_EXTEND, MVT::v16i32, MVT::v16i8, 6 },
{ ISD::ZERO_EXTEND, MVT::v16i32, MVT::v16i8, 6 },
// Operations that we legalize using splitting.
{ ISD::TRUNCATE, MVT::v16i8, MVT::v16i32, 6 },
{ ISD::TRUNCATE, MVT::v8i8, MVT::v8i32, 3 },
// Vector float <-> i32 conversions.
{ ISD::SINT_TO_FP, MVT::v4f32, MVT::v4i32, 1 },
{ ISD::UINT_TO_FP, MVT::v4f32, MVT::v4i32, 1 },
{ ISD::SINT_TO_FP, MVT::v2f32, MVT::v2i8, 3 },
{ ISD::UINT_TO_FP, MVT::v2f32, MVT::v2i8, 3 },
{ ISD::SINT_TO_FP, MVT::v2f32, MVT::v2i16, 2 },
{ ISD::UINT_TO_FP, MVT::v2f32, MVT::v2i16, 2 },
{ ISD::SINT_TO_FP, MVT::v2f32, MVT::v2i32, 1 },
{ ISD::UINT_TO_FP, MVT::v2f32, MVT::v2i32, 1 },
{ ISD::SINT_TO_FP, MVT::v4f32, MVT::v4i1, 3 },
{ ISD::UINT_TO_FP, MVT::v4f32, MVT::v4i1, 3 },
{ ISD::SINT_TO_FP, MVT::v4f32, MVT::v4i8, 3 },
{ ISD::UINT_TO_FP, MVT::v4f32, MVT::v4i8, 3 },
{ ISD::SINT_TO_FP, MVT::v4f32, MVT::v4i16, 2 },
{ ISD::UINT_TO_FP, MVT::v4f32, MVT::v4i16, 2 },
{ ISD::SINT_TO_FP, MVT::v8f32, MVT::v8i16, 4 },
{ ISD::UINT_TO_FP, MVT::v8f32, MVT::v8i16, 4 },
{ ISD::SINT_TO_FP, MVT::v8f32, MVT::v8i32, 2 },
{ ISD::UINT_TO_FP, MVT::v8f32, MVT::v8i32, 2 },
{ ISD::SINT_TO_FP, MVT::v16f32, MVT::v16i16, 8 },
{ ISD::UINT_TO_FP, MVT::v16f32, MVT::v16i16, 8 },
{ ISD::SINT_TO_FP, MVT::v16f32, MVT::v16i32, 4 },
{ ISD::UINT_TO_FP, MVT::v16f32, MVT::v16i32, 4 },
{ ISD::FP_TO_SINT, MVT::v4i32, MVT::v4f32, 1 },
{ ISD::FP_TO_UINT, MVT::v4i32, MVT::v4f32, 1 },
{ ISD::FP_TO_SINT, MVT::v4i8, MVT::v4f32, 3 },
{ ISD::FP_TO_UINT, MVT::v4i8, MVT::v4f32, 3 },
{ ISD::FP_TO_SINT, MVT::v4i16, MVT::v4f32, 2 },
{ ISD::FP_TO_UINT, MVT::v4i16, MVT::v4f32, 2 },
// Vector double <-> i32 conversions.
{ ISD::SINT_TO_FP, MVT::v2f64, MVT::v2i32, 2 },
{ ISD::UINT_TO_FP, MVT::v2f64, MVT::v2i32, 2 },
{ ISD::SINT_TO_FP, MVT::v2f64, MVT::v2i8, 4 },
{ ISD::UINT_TO_FP, MVT::v2f64, MVT::v2i8, 4 },
{ ISD::SINT_TO_FP, MVT::v2f64, MVT::v2i16, 3 },
{ ISD::UINT_TO_FP, MVT::v2f64, MVT::v2i16, 3 },
{ ISD::SINT_TO_FP, MVT::v2f64, MVT::v2i32, 2 },
{ ISD::UINT_TO_FP, MVT::v2f64, MVT::v2i32, 2 },
{ ISD::FP_TO_SINT, MVT::v2i32, MVT::v2f64, 2 },
{ ISD::FP_TO_UINT, MVT::v2i32, MVT::v2f64, 2 },
{ ISD::FP_TO_SINT, MVT::v8i16, MVT::v8f32, 4 },
{ ISD::FP_TO_UINT, MVT::v8i16, MVT::v8f32, 4 },
{ ISD::FP_TO_SINT, MVT::v16i16, MVT::v16f32, 8 },
{ ISD::FP_TO_UINT, MVT::v16i16, MVT::v16f32, 8 }
};
if (SrcTy.isVector() && ST->hasNEON()) {
if (const auto *Entry = ConvertCostTableLookup(NEONVectorConversionTbl, ISD,
DstTy.getSimpleVT(),
SrcTy.getSimpleVT()))
return Entry->Cost;
}
// Scalar float to integer conversions.
static const TypeConversionCostTblEntry NEONFloatConversionTbl[] = {
{ ISD::FP_TO_SINT, MVT::i1, MVT::f32, 2 },
{ ISD::FP_TO_UINT, MVT::i1, MVT::f32, 2 },
{ ISD::FP_TO_SINT, MVT::i1, MVT::f64, 2 },
{ ISD::FP_TO_UINT, MVT::i1, MVT::f64, 2 },
{ ISD::FP_TO_SINT, MVT::i8, MVT::f32, 2 },
{ ISD::FP_TO_UINT, MVT::i8, MVT::f32, 2 },
{ ISD::FP_TO_SINT, MVT::i8, MVT::f64, 2 },
{ ISD::FP_TO_UINT, MVT::i8, MVT::f64, 2 },
{ ISD::FP_TO_SINT, MVT::i16, MVT::f32, 2 },
{ ISD::FP_TO_UINT, MVT::i16, MVT::f32, 2 },
{ ISD::FP_TO_SINT, MVT::i16, MVT::f64, 2 },
{ ISD::FP_TO_UINT, MVT::i16, MVT::f64, 2 },
{ ISD::FP_TO_SINT, MVT::i32, MVT::f32, 2 },
{ ISD::FP_TO_UINT, MVT::i32, MVT::f32, 2 },
{ ISD::FP_TO_SINT, MVT::i32, MVT::f64, 2 },
{ ISD::FP_TO_UINT, MVT::i32, MVT::f64, 2 },
{ ISD::FP_TO_SINT, MVT::i64, MVT::f32, 10 },
{ ISD::FP_TO_UINT, MVT::i64, MVT::f32, 10 },
{ ISD::FP_TO_SINT, MVT::i64, MVT::f64, 10 },
{ ISD::FP_TO_UINT, MVT::i64, MVT::f64, 10 }
};
if (SrcTy.isFloatingPoint() && ST->hasNEON()) {
if (const auto *Entry = ConvertCostTableLookup(NEONFloatConversionTbl, ISD,
DstTy.getSimpleVT(),
SrcTy.getSimpleVT()))
return Entry->Cost;
}
// Scalar integer to float conversions.
static const TypeConversionCostTblEntry NEONIntegerConversionTbl[] = {
{ ISD::SINT_TO_FP, MVT::f32, MVT::i1, 2 },
{ ISD::UINT_TO_FP, MVT::f32, MVT::i1, 2 },
{ ISD::SINT_TO_FP, MVT::f64, MVT::i1, 2 },
{ ISD::UINT_TO_FP, MVT::f64, MVT::i1, 2 },
{ ISD::SINT_TO_FP, MVT::f32, MVT::i8, 2 },
{ ISD::UINT_TO_FP, MVT::f32, MVT::i8, 2 },
{ ISD::SINT_TO_FP, MVT::f64, MVT::i8, 2 },
{ ISD::UINT_TO_FP, MVT::f64, MVT::i8, 2 },
{ ISD::SINT_TO_FP, MVT::f32, MVT::i16, 2 },
{ ISD::UINT_TO_FP, MVT::f32, MVT::i16, 2 },
{ ISD::SINT_TO_FP, MVT::f64, MVT::i16, 2 },
{ ISD::UINT_TO_FP, MVT::f64, MVT::i16, 2 },
{ ISD::SINT_TO_FP, MVT::f32, MVT::i32, 2 },
{ ISD::UINT_TO_FP, MVT::f32, MVT::i32, 2 },
{ ISD::SINT_TO_FP, MVT::f64, MVT::i32, 2 },
{ ISD::UINT_TO_FP, MVT::f64, MVT::i32, 2 },
{ ISD::SINT_TO_FP, MVT::f32, MVT::i64, 10 },
{ ISD::UINT_TO_FP, MVT::f32, MVT::i64, 10 },
{ ISD::SINT_TO_FP, MVT::f64, MVT::i64, 10 },
{ ISD::UINT_TO_FP, MVT::f64, MVT::i64, 10 }
};
if (SrcTy.isInteger() && ST->hasNEON()) {
if (const auto *Entry = ConvertCostTableLookup(NEONIntegerConversionTbl,
ISD, DstTy.getSimpleVT(),
SrcTy.getSimpleVT()))
return Entry->Cost;
}
// MVE extend costs, taken from codegen tests. i8->i16 or i16->i32 is one
// instruction, i8->i32 is two. i64 zexts are an VAND with a constant, sext
// are linearised so take more.
static const TypeConversionCostTblEntry MVEVectorConversionTbl[] = {
{ ISD::SIGN_EXTEND, MVT::v8i16, MVT::v8i8, 1 },
{ ISD::ZERO_EXTEND, MVT::v8i16, MVT::v8i8, 1 },
{ ISD::SIGN_EXTEND, MVT::v4i32, MVT::v4i8, 2 },
{ ISD::ZERO_EXTEND, MVT::v4i32, MVT::v4i8, 2 },
{ ISD::SIGN_EXTEND, MVT::v2i64, MVT::v2i8, 10 },
{ ISD::ZERO_EXTEND, MVT::v2i64, MVT::v2i8, 2 },
{ ISD::SIGN_EXTEND, MVT::v4i32, MVT::v4i16, 1 },
{ ISD::ZERO_EXTEND, MVT::v4i32, MVT::v4i16, 1 },
{ ISD::SIGN_EXTEND, MVT::v2i64, MVT::v2i16, 10 },
{ ISD::ZERO_EXTEND, MVT::v2i64, MVT::v2i16, 2 },
{ ISD::SIGN_EXTEND, MVT::v2i64, MVT::v2i32, 8 },
{ ISD::ZERO_EXTEND, MVT::v2i64, MVT::v2i32, 2 },
};
if (SrcTy.isVector() && ST->hasMVEIntegerOps()) {
if (const auto *Entry = ConvertCostTableLookup(MVEVectorConversionTbl,
ISD, DstTy.getSimpleVT(),
SrcTy.getSimpleVT()))
return Entry->Cost * ST->getMVEVectorCostFactor();
}
// Scalar integer conversion costs.
static const TypeConversionCostTblEntry ARMIntegerConversionTbl[] = {
// i16 -> i64 requires two dependent operations.
{ ISD::SIGN_EXTEND, MVT::i64, MVT::i16, 2 },
// Truncates on i64 are assumed to be free.
{ ISD::TRUNCATE, MVT::i32, MVT::i64, 0 },
{ ISD::TRUNCATE, MVT::i16, MVT::i64, 0 },
{ ISD::TRUNCATE, MVT::i8, MVT::i64, 0 },
{ ISD::TRUNCATE, MVT::i1, MVT::i64, 0 }
};
if (SrcTy.isInteger()) {
if (const auto *Entry = ConvertCostTableLookup(ARMIntegerConversionTbl, ISD,
DstTy.getSimpleVT(),
SrcTy.getSimpleVT()))
return Entry->Cost;
}
int BaseCost = ST->hasMVEIntegerOps() && Src->isVectorTy()
? ST->getMVEVectorCostFactor()
: 1;
return BaseCost * BaseT::getCastInstrCost(Opcode, Dst, Src);
}
int ARMTTIImpl::getVectorInstrCost(unsigned Opcode, Type *ValTy,
unsigned Index) {
// Penalize inserting into an D-subregister. We end up with a three times
// lower estimated throughput on swift.
if (ST->hasSlowLoadDSubregister() && Opcode == Instruction::InsertElement &&
ValTy->isVectorTy() && ValTy->getScalarSizeInBits() <= 32)
return 3;
if (ST->hasNEON() && (Opcode == Instruction::InsertElement ||
Opcode == Instruction::ExtractElement)) {
// Cross-class copies are expensive on many microarchitectures,
// so assume they are expensive by default.
if (ValTy->getVectorElementType()->isIntegerTy())
return 3;
// Even if it's not a cross class copy, this likely leads to mixing
// of NEON and VFP code and should be therefore penalized.
if (ValTy->isVectorTy() &&
ValTy->getScalarSizeInBits() <= 32)
return std::max(BaseT::getVectorInstrCost(Opcode, ValTy, Index), 2U);
}
if (ST->hasMVEIntegerOps() && (Opcode == Instruction::InsertElement ||
Opcode == Instruction::ExtractElement)) {
// We say MVE moves costs at least the MVEVectorCostFactor, even though
// they are scalar instructions. This helps prevent mixing scalar and
// vector, to prevent vectorising where we end up just scalarising the
// result anyway.
return std::max(BaseT::getVectorInstrCost(Opcode, ValTy, Index),
ST->getMVEVectorCostFactor()) *
ValTy->getVectorNumElements() / 2;
}
return BaseT::getVectorInstrCost(Opcode, ValTy, Index);
}
int ARMTTIImpl::getCmpSelInstrCost(unsigned Opcode, Type *ValTy, Type *CondTy,
const Instruction *I) {
int ISD = TLI->InstructionOpcodeToISD(Opcode);
// On NEON a vector select gets lowered to vbsl.
if (ST->hasNEON() && ValTy->isVectorTy() && ISD == ISD::SELECT) {
// Lowering of some vector selects is currently far from perfect.
static const TypeConversionCostTblEntry NEONVectorSelectTbl[] = {
{ ISD::SELECT, MVT::v4i1, MVT::v4i64, 4*4 + 1*2 + 1 },
{ ISD::SELECT, MVT::v8i1, MVT::v8i64, 50 },
{ ISD::SELECT, MVT::v16i1, MVT::v16i64, 100 }
};
EVT SelCondTy = TLI->getValueType(DL, CondTy);
EVT SelValTy = TLI->getValueType(DL, ValTy);
if (SelCondTy.isSimple() && SelValTy.isSimple()) {
if (const auto *Entry = ConvertCostTableLookup(NEONVectorSelectTbl, ISD,
SelCondTy.getSimpleVT(),
SelValTy.getSimpleVT()))
return Entry->Cost;
}
std::pair<int, MVT> LT = TLI->getTypeLegalizationCost(DL, ValTy);
return LT.first;
}
int BaseCost = ST->hasMVEIntegerOps() && ValTy->isVectorTy()
? ST->getMVEVectorCostFactor()
: 1;
return BaseCost * BaseT::getCmpSelInstrCost(Opcode, ValTy, CondTy, I);
}
int ARMTTIImpl::getAddressComputationCost(Type *Ty, ScalarEvolution *SE,
const SCEV *Ptr) {
// Address computations in vectorized code with non-consecutive addresses will
// likely result in more instructions compared to scalar code where the
// computation can more often be merged into the index mode. The resulting
// extra micro-ops can significantly decrease throughput.
unsigned NumVectorInstToHideOverhead = 10;
int MaxMergeDistance = 64;
if (ST->hasNEON()) {
if (Ty->isVectorTy() && SE &&
!BaseT::isConstantStridedAccessLessThan(SE, Ptr, MaxMergeDistance + 1))
return NumVectorInstToHideOverhead;
// In many cases the address computation is not merged into the instruction
// addressing mode.
return 1;
}
return BaseT::getAddressComputationCost(Ty, SE, Ptr);
}
bool ARMTTIImpl::isLegalMaskedLoad(Type *DataTy, MaybeAlign Alignment) {
if (!EnableMaskedLoadStores || !ST->hasMVEIntegerOps())
return false;
if (auto *VecTy = dyn_cast<VectorType>(DataTy)) {
// Don't support v2i1 yet.
if (VecTy->getNumElements() == 2)
return false;
// We don't support extending fp types.
unsigned VecWidth = DataTy->getPrimitiveSizeInBits();
if (VecWidth != 128 && VecTy->getElementType()->isFloatingPointTy())
return false;
}
unsigned EltWidth = DataTy->getScalarSizeInBits();
return (EltWidth == 32 && (!Alignment || Alignment >= 4)) ||
(EltWidth == 16 && (!Alignment || Alignment >= 2)) ||
(EltWidth == 8);
}
bool ARMTTIImpl::isLegalMaskedGather(Type *Ty, MaybeAlign Alignment) {
if (!EnableMaskedGatherScatters || !ST->hasMVEIntegerOps())
return false;
// This method is called in 2 places:
// - from the vectorizer with a scalar type, in which case we need to get
// this as good as we can with the limited info we have (and rely on the cost
// model for the rest).
// - from the masked intrinsic lowering pass with the actual vector type.
// For MVE, we have a custom lowering pass that will already have custom
// legalised any gathers that we can to MVE intrinsics, and want to expand all
// the rest. The pass runs before the masked intrinsic lowering pass, so if we
// are here, we know we want to expand.
if (isa<VectorType>(Ty))
return false;
unsigned EltWidth = Ty->getScalarSizeInBits();
return ((EltWidth == 32 && (!Alignment || Alignment >= 4)) ||
(EltWidth == 16 && (!Alignment || Alignment >= 2)) || EltWidth == 8);
}
int ARMTTIImpl::getMemcpyCost(const Instruction *I) {
const MemCpyInst *MI = dyn_cast<MemCpyInst>(I);
assert(MI && "MemcpyInst expected");
ConstantInt *C = dyn_cast<ConstantInt>(MI->getLength());
// To model the cost of a library call, we assume 1 for the call, and
// 3 for the argument setup.
const unsigned LibCallCost = 4;
// If 'size' is not a constant, a library call will be generated.
if (!C)
return LibCallCost;
const unsigned Size = C->getValue().getZExtValue();
const Align DstAlign = *MI->getDestAlign();
const Align SrcAlign = *MI->getSourceAlign();
const Function *F = I->getParent()->getParent();
const unsigned Limit = TLI->getMaxStoresPerMemmove(F->hasMinSize());
std::vector<EVT> MemOps;
// MemOps will be poplulated with a list of data types that needs to be
// loaded and stored. That's why we multiply the number of elements by 2 to
// get the cost for this memcpy.
if (getTLI()->findOptimalMemOpLowering(
MemOps, Limit,
MemOp::Copy(Size, /*DstAlignCanChange*/ false, DstAlign, SrcAlign,
/*IsVolatile*/ true),
MI->getDestAddressSpace(), MI->getSourceAddressSpace(),
F->getAttributes()))
return MemOps.size() * 2;
// If we can't find an optimal memop lowering, return the default cost
return LibCallCost;
}
int ARMTTIImpl::getShuffleCost(TTI::ShuffleKind Kind, Type *Tp, int Index,
Type *SubTp) {
if (ST->hasNEON()) {
if (Kind == TTI::SK_Broadcast) {
static const CostTblEntry NEONDupTbl[] = {
// VDUP handles these cases.
{ISD::VECTOR_SHUFFLE, MVT::v2i32, 1},
{ISD::VECTOR_SHUFFLE, MVT::v2f32, 1},
{ISD::VECTOR_SHUFFLE, MVT::v2i64, 1},
{ISD::VECTOR_SHUFFLE, MVT::v2f64, 1},
{ISD::VECTOR_SHUFFLE, MVT::v4i16, 1},
{ISD::VECTOR_SHUFFLE, MVT::v8i8, 1},
{ISD::VECTOR_SHUFFLE, MVT::v4i32, 1},
{ISD::VECTOR_SHUFFLE, MVT::v4f32, 1},
{ISD::VECTOR_SHUFFLE, MVT::v8i16, 1},
{ISD::VECTOR_SHUFFLE, MVT::v16i8, 1}};
std::pair<int, MVT> LT = TLI->getTypeLegalizationCost(DL, Tp);
if (const auto *Entry =
CostTableLookup(NEONDupTbl, ISD::VECTOR_SHUFFLE, LT.second))
return LT.first * Entry->Cost;
}
if (Kind == TTI::SK_Reverse) {
static const CostTblEntry NEONShuffleTbl[] = {
// Reverse shuffle cost one instruction if we are shuffling within a
// double word (vrev) or two if we shuffle a quad word (vrev, vext).
{ISD::VECTOR_SHUFFLE, MVT::v2i32, 1},
{ISD::VECTOR_SHUFFLE, MVT::v2f32, 1},
{ISD::VECTOR_SHUFFLE, MVT::v2i64, 1},
{ISD::VECTOR_SHUFFLE, MVT::v2f64, 1},
{ISD::VECTOR_SHUFFLE, MVT::v4i16, 1},
{ISD::VECTOR_SHUFFLE, MVT::v8i8, 1},
{ISD::VECTOR_SHUFFLE, MVT::v4i32, 2},
{ISD::VECTOR_SHUFFLE, MVT::v4f32, 2},
{ISD::VECTOR_SHUFFLE, MVT::v8i16, 2},
{ISD::VECTOR_SHUFFLE, MVT::v16i8, 2}};
std::pair<int, MVT> LT = TLI->getTypeLegalizationCost(DL, Tp);
if (const auto *Entry =
CostTableLookup(NEONShuffleTbl, ISD::VECTOR_SHUFFLE, LT.second))
return LT.first * Entry->Cost;
}
if (Kind == TTI::SK_Select) {
static const CostTblEntry NEONSelShuffleTbl[] = {
// Select shuffle cost table for ARM. Cost is the number of
// instructions
// required to create the shuffled vector.
{ISD::VECTOR_SHUFFLE, MVT::v2f32, 1},
{ISD::VECTOR_SHUFFLE, MVT::v2i64, 1},
{ISD::VECTOR_SHUFFLE, MVT::v2f64, 1},
{ISD::VECTOR_SHUFFLE, MVT::v2i32, 1},
{ISD::VECTOR_SHUFFLE, MVT::v4i32, 2},
{ISD::VECTOR_SHUFFLE, MVT::v4f32, 2},
{ISD::VECTOR_SHUFFLE, MVT::v4i16, 2},
{ISD::VECTOR_SHUFFLE, MVT::v8i16, 16},
{ISD::VECTOR_SHUFFLE, MVT::v16i8, 32}};
std::pair<int, MVT> LT = TLI->getTypeLegalizationCost(DL, Tp);
if (const auto *Entry = CostTableLookup(NEONSelShuffleTbl,
ISD::VECTOR_SHUFFLE, LT.second))
return LT.first * Entry->Cost;
}
}
if (ST->hasMVEIntegerOps()) {
if (Kind == TTI::SK_Broadcast) {
static const CostTblEntry MVEDupTbl[] = {
// VDUP handles these cases.
{ISD::VECTOR_SHUFFLE, MVT::v4i32, 1},
{ISD::VECTOR_SHUFFLE, MVT::v8i16, 1},
{ISD::VECTOR_SHUFFLE, MVT::v16i8, 1},
{ISD::VECTOR_SHUFFLE, MVT::v4f32, 1},
{ISD::VECTOR_SHUFFLE, MVT::v8f16, 1}};
std::pair<int, MVT> LT = TLI->getTypeLegalizationCost(DL, Tp);
if (const auto *Entry = CostTableLookup(MVEDupTbl, ISD::VECTOR_SHUFFLE,
LT.second))
return LT.first * Entry->Cost * ST->getMVEVectorCostFactor();
}
}
int BaseCost = ST->hasMVEIntegerOps() && Tp->isVectorTy()
? ST->getMVEVectorCostFactor()
: 1;
return BaseCost * BaseT::getShuffleCost(Kind, Tp, Index, SubTp);
}
int ARMTTIImpl::getArithmeticInstrCost(unsigned Opcode, Type *Ty,
TTI::OperandValueKind Op1Info,
TTI::OperandValueKind Op2Info,
TTI::OperandValueProperties Opd1PropInfo,
TTI::OperandValueProperties Opd2PropInfo,
ArrayRef<const Value *> Args,
const Instruction *CxtI) {
int ISDOpcode = TLI->InstructionOpcodeToISD(Opcode);
std::pair<int, MVT> LT = TLI->getTypeLegalizationCost(DL, Ty);
if (ST->hasNEON()) {
const unsigned FunctionCallDivCost = 20;
const unsigned ReciprocalDivCost = 10;
static const CostTblEntry CostTbl[] = {
// Division.
// These costs are somewhat random. Choose a cost of 20 to indicate that
// vectorizing devision (added function call) is going to be very expensive.
// Double registers types.
{ ISD::SDIV, MVT::v1i64, 1 * FunctionCallDivCost},
{ ISD::UDIV, MVT::v1i64, 1 * FunctionCallDivCost},
{ ISD::SREM, MVT::v1i64, 1 * FunctionCallDivCost},
{ ISD::UREM, MVT::v1i64, 1 * FunctionCallDivCost},
{ ISD::SDIV, MVT::v2i32, 2 * FunctionCallDivCost},
{ ISD::UDIV, MVT::v2i32, 2 * FunctionCallDivCost},
{ ISD::SREM, MVT::v2i32, 2 * FunctionCallDivCost},
{ ISD::UREM, MVT::v2i32, 2 * FunctionCallDivCost},
{ ISD::SDIV, MVT::v4i16, ReciprocalDivCost},
{ ISD::UDIV, MVT::v4i16, ReciprocalDivCost},
{ ISD::SREM, MVT::v4i16, 4 * FunctionCallDivCost},
{ ISD::UREM, MVT::v4i16, 4 * FunctionCallDivCost},
{ ISD::SDIV, MVT::v8i8, ReciprocalDivCost},
{ ISD::UDIV, MVT::v8i8, ReciprocalDivCost},
{ ISD::SREM, MVT::v8i8, 8 * FunctionCallDivCost},
{ ISD::UREM, MVT::v8i8, 8 * FunctionCallDivCost},
// Quad register types.
{ ISD::SDIV, MVT::v2i64, 2 * FunctionCallDivCost},
{ ISD::UDIV, MVT::v2i64, 2 * FunctionCallDivCost},
{ ISD::SREM, MVT::v2i64, 2 * FunctionCallDivCost},
{ ISD::UREM, MVT::v2i64, 2 * FunctionCallDivCost},
{ ISD::SDIV, MVT::v4i32, 4 * FunctionCallDivCost},
{ ISD::UDIV, MVT::v4i32, 4 * FunctionCallDivCost},
{ ISD::SREM, MVT::v4i32, 4 * FunctionCallDivCost},
{ ISD::UREM, MVT::v4i32, 4 * FunctionCallDivCost},
{ ISD::SDIV, MVT::v8i16, 8 * FunctionCallDivCost},
{ ISD::UDIV, MVT::v8i16, 8 * FunctionCallDivCost},
{ ISD::SREM, MVT::v8i16, 8 * FunctionCallDivCost},
{ ISD::UREM, MVT::v8i16, 8 * FunctionCallDivCost},
{ ISD::SDIV, MVT::v16i8, 16 * FunctionCallDivCost},
{ ISD::UDIV, MVT::v16i8, 16 * FunctionCallDivCost},
{ ISD::SREM, MVT::v16i8, 16 * FunctionCallDivCost},
{ ISD::UREM, MVT::v16i8, 16 * FunctionCallDivCost},
// Multiplication.
};
if (const auto *Entry = CostTableLookup(CostTbl, ISDOpcode, LT.second))
return LT.first * Entry->Cost;
int Cost = BaseT::getArithmeticInstrCost(Opcode, Ty, Op1Info, Op2Info,
Opd1PropInfo, Opd2PropInfo);
// This is somewhat of a hack. The problem that we are facing is that SROA
// creates a sequence of shift, and, or instructions to construct values.
// These sequences are recognized by the ISel and have zero-cost. Not so for
// the vectorized code. Because we have support for v2i64 but not i64 those
// sequences look particularly beneficial to vectorize.
// To work around this we increase the cost of v2i64 operations to make them
// seem less beneficial.
if (LT.second == MVT::v2i64 &&
Op2Info == TargetTransformInfo::OK_UniformConstantValue)
Cost += 4;
return Cost;
}
// If this operation is a shift on arm/thumb2, it might well be folded into
// the following instruction, hence having a cost of 0.
auto LooksLikeAFreeShift = [&]() {
if (ST->isThumb1Only() || Ty->isVectorTy())
return false;
if (!CxtI || !CxtI->hasOneUse() || !CxtI->isShift())
return false;
if (Op2Info != TargetTransformInfo::OK_UniformConstantValue)
return false;
// Folded into a ADC/ADD/AND/BIC/CMP/EOR/MVN/ORR/ORN/RSB/SBC/SUB
switch (cast<Instruction>(CxtI->user_back())->getOpcode()) {
case Instruction::Add:
case Instruction::Sub:
case Instruction::And:
case Instruction::Xor:
case Instruction::Or:
case Instruction::ICmp:
return true;
default:
return false;
}
};
if (LooksLikeAFreeShift())
return 0;
int BaseCost = ST->hasMVEIntegerOps() && Ty->isVectorTy()
? ST->getMVEVectorCostFactor()
: 1;
// The rest of this mostly follows what is done in BaseT::getArithmeticInstrCost,
// without treating floats as more expensive that scalars or increasing the
// costs for custom operations. The results is also multiplied by the
// MVEVectorCostFactor where appropriate.
if (TLI->isOperationLegalOrCustomOrPromote(ISDOpcode, LT.second))
return LT.first * BaseCost;
// Else this is expand, assume that we need to scalarize this op.
if (Ty->isVectorTy()) {
unsigned Num = Ty->getVectorNumElements();
unsigned Cost = getArithmeticInstrCost(Opcode, Ty->getScalarType());
// Return the cost of multiple scalar invocation plus the cost of
// inserting and extracting the values.
return BaseT::getScalarizationOverhead(Ty, Args) + Num * Cost;
}
return BaseCost;
}
int ARMTTIImpl::getMemoryOpCost(unsigned Opcode, Type *Src,
MaybeAlign Alignment, unsigned AddressSpace,
const Instruction *I) {
std::pair<int, MVT> LT = TLI->getTypeLegalizationCost(DL, Src);
if (ST->hasNEON() && Src->isVectorTy() &&
(Alignment && *Alignment != Align(16)) &&
Src->getVectorElementType()->isDoubleTy()) {
// Unaligned loads/stores are extremely inefficient.
// We need 4 uops for vst.1/vld.1 vs 1uop for vldr/vstr.
return LT.first * 4;
}
int BaseCost = ST->hasMVEIntegerOps() && Src->isVectorTy()
? ST->getMVEVectorCostFactor()
: 1;
return BaseCost * LT.first;
}
int ARMTTIImpl::getInterleavedMemoryOpCost(
unsigned Opcode, Type *VecTy, unsigned Factor, ArrayRef<unsigned> Indices,
unsigned Alignment, unsigned AddressSpace, bool UseMaskForCond,
bool UseMaskForGaps) {
assert(Factor >= 2 && "Invalid interleave factor");
assert(isa<VectorType>(VecTy) && "Expect a vector type");
// vldN/vstN doesn't support vector types of i64/f64 element.
bool EltIs64Bits = DL.getTypeSizeInBits(VecTy->getScalarType()) == 64;
if (Factor <= TLI->getMaxSupportedInterleaveFactor() && !EltIs64Bits &&
!UseMaskForCond && !UseMaskForGaps) {
unsigned NumElts = VecTy->getVectorNumElements();
auto *SubVecTy = VectorType::get(VecTy->getScalarType(), NumElts / Factor);
// vldN/vstN only support legal vector types of size 64 or 128 in bits.
// Accesses having vector types that are a multiple of 128 bits can be
// matched to more than one vldN/vstN instruction.
int BaseCost = ST->hasMVEIntegerOps() ? ST->getMVEVectorCostFactor() : 1;
if (NumElts % Factor == 0 &&
TLI->isLegalInterleavedAccessType(Factor, SubVecTy, DL))
return Factor * BaseCost * TLI->getNumInterleavedAccesses(SubVecTy, DL);
// Some smaller than legal interleaved patterns are cheap as we can make
// use of the vmovn or vrev patterns to interleave a standard load. This is
// true for v4i8, v8i8 and v4i16 at least (but not for v4f16 as it is
// promoted differently). The cost of 2 here is then a load and vrev or
// vmovn.
if (ST->hasMVEIntegerOps() && Factor == 2 && NumElts / Factor > 2 &&
VecTy->isIntOrIntVectorTy() && DL.getTypeSizeInBits(SubVecTy) <= 64)
return 2 * BaseCost;
}
return BaseT::getInterleavedMemoryOpCost(Opcode, VecTy, Factor, Indices,
Alignment, AddressSpace,
UseMaskForCond, UseMaskForGaps);
}
unsigned ARMTTIImpl::getGatherScatterOpCost(unsigned Opcode, Type *DataTy,
Value *Ptr, bool VariableMask,
unsigned Alignment) {
if (!ST->hasMVEIntegerOps() || !EnableMaskedGatherScatters)
return BaseT::getGatherScatterOpCost(Opcode, DataTy, Ptr, VariableMask,
Alignment);
assert(DataTy->isVectorTy() && "Can't do gather/scatters on scalar!");
VectorType *VTy = cast<VectorType>(DataTy);
// TODO: Splitting, once we do that.
// TODO: trunc/sext/zext the result/input
unsigned NumElems = VTy->getNumElements();
unsigned EltSize = VTy->getScalarSizeInBits();
std::pair<int, MVT> LT = TLI->getTypeLegalizationCost(DL, DataTy);
// For now, it is assumed that for the MVE gather instructions the loads are
// all effectively serialised. This means the cost is the scalar cost
// multiplied by the number of elements being loaded. This is possibly very
// conservative, but even so we still end up vectorising loops because the
// cost per iteration for many loops is lower than for scalar loops.
unsigned VectorCost = NumElems * LT.first;
// The scalarization cost should be a lot higher. We use the number of vector
// elements plus the scalarization overhead.
unsigned ScalarCost =
NumElems * LT.first + BaseT::getScalarizationOverhead(DataTy, {});
// TODO: Cost extended gathers or trunc stores correctly.
if (EltSize * NumElems != 128 || NumElems < 4)
return ScalarCost;
if (Alignment < EltSize / 8)
return ScalarCost;
// Any (aligned) i32 gather will not need to be scalarised.
if (EltSize == 32)
return VectorCost;
// For smaller types, we need to ensure that the gep's inputs are correctly
// extended from a small enough value. Other size (including i64) are
// scalarized for now.
if (EltSize != 8 && EltSize != 16)
return ScalarCost;
if (auto BC = dyn_cast<BitCastInst>(Ptr))
Ptr = BC->getOperand(0);
if (auto *GEP = dyn_cast<GetElementPtrInst>(Ptr)) {
if (GEP->getNumOperands() != 2)
return ScalarCost;
unsigned Scale = DL.getTypeAllocSize(GEP->getResultElementType());
// Scale needs to be correct (which is only relevant for i16s).
if (Scale != 1 && Scale * 8 != EltSize)
return ScalarCost;
// And we need to zext (not sext) the indexes from a small enough type.
if (auto ZExt = dyn_cast<ZExtInst>(GEP->getOperand(1)))
if (ZExt->getOperand(0)->getType()->getScalarSizeInBits() <= EltSize)
return VectorCost;
return ScalarCost;
}
return ScalarCost;
}
bool ARMTTIImpl::isLoweredToCall(const Function *F) {
if (!F->isIntrinsic())
BaseT::isLoweredToCall(F);
// Assume all Arm-specific intrinsics map to an instruction.
if (F->getName().startswith("llvm.arm"))
return false;
switch (F->getIntrinsicID()) {
default: break;
case Intrinsic::powi:
case Intrinsic::sin:
case Intrinsic::cos:
case Intrinsic::pow:
case Intrinsic::log:
case Intrinsic::log10:
case Intrinsic::log2:
case Intrinsic::exp:
case Intrinsic::exp2:
return true;
case Intrinsic::sqrt:
case Intrinsic::fabs:
case Intrinsic::copysign:
case Intrinsic::floor:
case Intrinsic::ceil:
case Intrinsic::trunc:
case Intrinsic::rint:
case Intrinsic::nearbyint:
case Intrinsic::round:
case Intrinsic::canonicalize:
case Intrinsic::lround:
case Intrinsic::llround:
case Intrinsic::lrint:
case Intrinsic::llrint:
if (F->getReturnType()->isDoubleTy() && !ST->hasFP64())
return true;
if (F->getReturnType()->isHalfTy() && !ST->hasFullFP16())
return true;
// Some operations can be handled by vector instructions and assume
// unsupported vectors will be expanded into supported scalar ones.
// TODO Handle scalar operations properly.
return !ST->hasFPARMv8Base() && !ST->hasVFP2Base();
case Intrinsic::masked_store:
case Intrinsic::masked_load:
case Intrinsic::masked_gather:
case Intrinsic::masked_scatter:
return !ST->hasMVEIntegerOps();
case Intrinsic::sadd_with_overflow:
case Intrinsic::uadd_with_overflow:
case Intrinsic::ssub_with_overflow:
case Intrinsic::usub_with_overflow:
case Intrinsic::sadd_sat:
case Intrinsic::uadd_sat:
case Intrinsic::ssub_sat:
case Intrinsic::usub_sat:
return false;
}
return BaseT::isLoweredToCall(F);
}
bool ARMTTIImpl::isHardwareLoopProfitable(Loop *L, ScalarEvolution &SE,
AssumptionCache &AC,
TargetLibraryInfo *LibInfo,
HardwareLoopInfo &HWLoopInfo) {
// Low-overhead branches are only supported in the 'low-overhead branch'
// extension of v8.1-m.
if (!ST->hasLOB() || DisableLowOverheadLoops)
return false;
if (!SE.hasLoopInvariantBackedgeTakenCount(L))
return false;
const SCEV *BackedgeTakenCount = SE.getBackedgeTakenCount(L);
if (isa<SCEVCouldNotCompute>(BackedgeTakenCount))
return false;
const SCEV *TripCountSCEV =
SE.getAddExpr(BackedgeTakenCount,
SE.getOne(BackedgeTakenCount->getType()));
// We need to store the trip count in LR, a 32-bit register.
if (SE.getUnsignedRangeMax(TripCountSCEV).getBitWidth() > 32)
return false;
// Making a call will trash LR and clear LO_BRANCH_INFO, so there's little
// point in generating a hardware loop if that's going to happen.
auto MaybeCall = [this](Instruction &I) {
const ARMTargetLowering *TLI = getTLI();
unsigned ISD = TLI->InstructionOpcodeToISD(I.getOpcode());
EVT VT = TLI->getValueType(DL, I.getType(), true);
if (TLI->getOperationAction(ISD, VT) == TargetLowering::LibCall)
return true;
// Check if an intrinsic will be lowered to a call and assume that any
// other CallInst will generate a bl.
if (auto *Call = dyn_cast<CallInst>(&I)) {
if (isa<IntrinsicInst>(Call)) {
if (const Function *F = Call->getCalledFunction())
return isLoweredToCall(F);
}
return true;
}
// FPv5 provides conversions between integer, double-precision,
// single-precision, and half-precision formats.
switch (I.getOpcode()) {
default:
break;
case Instruction::FPToSI:
case Instruction::FPToUI:
case Instruction::SIToFP:
case Instruction::UIToFP:
case Instruction::FPTrunc:
case Instruction::FPExt:
return !ST->hasFPARMv8Base();
}
// FIXME: Unfortunately the approach of checking the Operation Action does
// not catch all cases of Legalization that use library calls. Our
// Legalization step categorizes some transformations into library calls as
// Custom, Expand or even Legal when doing type legalization. So for now
// we have to special case for instance the SDIV of 64bit integers and the
// use of floating point emulation.
if (VT.isInteger() && VT.getSizeInBits() >= 64) {
switch (ISD) {
default:
break;
case ISD::SDIV:
case ISD::UDIV:
case ISD::SREM:
case ISD::UREM:
case ISD::SDIVREM:
case ISD::UDIVREM:
return true;
}
}
// Assume all other non-float operations are supported.
if (!VT.isFloatingPoint())
return false;
// We'll need a library call to handle most floats when using soft.
if (TLI->useSoftFloat()) {
switch (I.getOpcode()) {
default:
return true;
case Instruction::Alloca:
case Instruction::Load:
case Instruction::Store:
case Instruction::Select:
case Instruction::PHI:
return false;
}
}
// We'll need a libcall to perform double precision operations on a single
// precision only FPU.
if (I.getType()->isDoubleTy() && !ST->hasFP64())
return true;
// Likewise for half precision arithmetic.
if (I.getType()->isHalfTy() && !ST->hasFullFP16())
return true;
return false;
};
auto IsHardwareLoopIntrinsic = [](Instruction &I) {
if (auto *Call = dyn_cast<IntrinsicInst>(&I)) {
switch (Call->getIntrinsicID()) {
default:
break;
case Intrinsic::set_loop_iterations:
case Intrinsic::test_set_loop_iterations:
case Intrinsic::loop_decrement:
case Intrinsic::loop_decrement_reg:
return true;
}
}
return false;
};
// Scan the instructions to see if there's any that we know will turn into a
// call or if this loop is already a low-overhead loop.
auto ScanLoop = [&](Loop *L) {
for (auto *BB : L->getBlocks()) {
for (auto &I : *BB) {
if (MaybeCall(I) || IsHardwareLoopIntrinsic(I))
return false;
}
}
return true;
};
// Visit inner loops.
for (auto Inner : *L)
if (!ScanLoop(Inner))
return false;
if (!ScanLoop(L))
return false;
// TODO: Check whether the trip count calculation is expensive. If L is the
// inner loop but we know it has a low trip count, calculating that trip
// count (in the parent loop) may be detrimental.
LLVMContext &C = L->getHeader()->getContext();
HWLoopInfo.CounterInReg = true;
HWLoopInfo.IsNestingLegal = false;
HWLoopInfo.PerformEntryTest = true;
HWLoopInfo.CountType = Type::getInt32Ty(C);
HWLoopInfo.LoopDecrement = ConstantInt::get(HWLoopInfo.CountType, 1);
return true;
}
static bool canTailPredicateInstruction(Instruction &I, int &ICmpCount) {
// We don't allow icmp's, and because we only look at single block loops,
// we simply count the icmps, i.e. there should only be 1 for the backedge.
if (isa<ICmpInst>(&I) && ++ICmpCount > 1)
return false;
if (isa<FCmpInst>(&I))
return false;
// We could allow extending/narrowing FP loads/stores, but codegen is
// too inefficient so reject this for now.
if (isa<FPExtInst>(&I) || isa<FPTruncInst>(&I))
return false;
// Extends have to be extending-loads
if (isa<SExtInst>(&I) || isa<ZExtInst>(&I) )
if (!I.getOperand(0)->hasOneUse() || !isa<LoadInst>(I.getOperand(0)))
return false;
// Truncs have to be narrowing-stores
if (isa<TruncInst>(&I) )
if (!I.hasOneUse() || !isa<StoreInst>(*I.user_begin()))
return false;
return true;
}
// To set up a tail-predicated loop, we need to know the total number of
// elements processed by that loop. Thus, we need to determine the element
// size and:
// 1) it should be uniform for all operations in the vector loop, so we
// e.g. don't want any widening/narrowing operations.
// 2) it should be smaller than i64s because we don't have vector operations
// that work on i64s.
// 3) we don't want elements to be reversed or shuffled, to make sure the
// tail-predication masks/predicates the right lanes.
//
static bool canTailPredicateLoop(Loop *L, LoopInfo *LI, ScalarEvolution &SE,
const DataLayout &DL,
const LoopAccessInfo *LAI) {
PredicatedScalarEvolution PSE = LAI->getPSE();
int ICmpCount = 0;
int Stride = 0;
LLVM_DEBUG(dbgs() << "tail-predication: checking allowed instructions\n");
SmallVector<Instruction *, 16> LoadStores;
for (BasicBlock *BB : L->blocks()) {
for (Instruction &I : BB->instructionsWithoutDebug()) {
if (isa<PHINode>(&I))
continue;
if (!canTailPredicateInstruction(I, ICmpCount)) {
LLVM_DEBUG(dbgs() << "Instruction not allowed: "; I.dump());
return false;
}
Type *T = I.getType();
if (T->isPointerTy())
T = T->getPointerElementType();
if (T->getScalarSizeInBits() > 32) {
LLVM_DEBUG(dbgs() << "Unsupported Type: "; T->dump());
return false;
}
if (isa<StoreInst>(I) || isa<LoadInst>(I)) {
Value *Ptr = isa<LoadInst>(I) ? I.getOperand(0) : I.getOperand(1);
int64_t NextStride = getPtrStride(PSE, Ptr, L);
// TODO: for now only allow consecutive strides of 1. We could support
// other strides as long as it is uniform, but let's keep it simple for
// now.
if (Stride == 0 && NextStride == 1) {
Stride = NextStride;
continue;
}
if (Stride != NextStride) {
LLVM_DEBUG(dbgs() << "Different strides found, can't "
"tail-predicate\n.");
return false;
}
}
}
}
LLVM_DEBUG(dbgs() << "tail-predication: all instructions allowed!\n");
return true;
}
bool ARMTTIImpl::preferPredicateOverEpilogue(Loop *L, LoopInfo *LI,
ScalarEvolution &SE,
AssumptionCache &AC,
TargetLibraryInfo *TLI,
DominatorTree *DT,
const LoopAccessInfo *LAI) {
if (DisableTailPredication)
return false;
// Creating a predicated vector loop is the first step for generating a
// tail-predicated hardware loop, for which we need the MVE masked
// load/stores instructions:
if (!ST->hasMVEIntegerOps())
return false;
// For now, restrict this to single block loops.
if (L->getNumBlocks() > 1) {
LLVM_DEBUG(dbgs() << "preferPredicateOverEpilogue: not a single block "
"loop.\n");
return false;
}
assert(L->empty() && "preferPredicateOverEpilogue: inner-loop expected");
HardwareLoopInfo HWLoopInfo(L);
if (!HWLoopInfo.canAnalyze(*LI)) {
LLVM_DEBUG(dbgs() << "preferPredicateOverEpilogue: hardware-loop is not "
"analyzable.\n");
return false;
}
// This checks if we have the low-overhead branch architecture
// extension, and if we will create a hardware-loop:
if (!isHardwareLoopProfitable(L, SE, AC, TLI, HWLoopInfo)) {
LLVM_DEBUG(dbgs() << "preferPredicateOverEpilogue: hardware-loop is not "
"profitable.\n");
return false;
}
if (!HWLoopInfo.isHardwareLoopCandidate(SE, *LI, *DT)) {
LLVM_DEBUG(dbgs() << "preferPredicateOverEpilogue: hardware-loop is not "
"a candidate.\n");
return false;
}
return canTailPredicateLoop(L, LI, SE, DL, LAI);
}
void ARMTTIImpl::getUnrollingPreferences(Loop *L, ScalarEvolution &SE,
TTI::UnrollingPreferences &UP) {
// Only currently enable these preferences for M-Class cores.
if (!ST->isMClass())
return BasicTTIImplBase::getUnrollingPreferences(L, SE, UP);
// Disable loop unrolling for Oz and Os.
UP.OptSizeThreshold = 0;
UP.PartialOptSizeThreshold = 0;
if (L->getHeader()->getParent()->hasOptSize())
return;
// Only enable on Thumb-2 targets.
if (!ST->isThumb2())
return;
SmallVector<BasicBlock*, 4> ExitingBlocks;
L->getExitingBlocks(ExitingBlocks);
LLVM_DEBUG(dbgs() << "Loop has:\n"
<< "Blocks: " << L->getNumBlocks() << "\n"
<< "Exit blocks: " << ExitingBlocks.size() << "\n");
// Only allow another exit other than the latch. This acts as an early exit
// as it mirrors the profitability calculation of the runtime unroller.
if (ExitingBlocks.size() > 2)
return;
// Limit the CFG of the loop body for targets with a branch predictor.
// Allowing 4 blocks permits if-then-else diamonds in the body.
if (ST->hasBranchPredictor() && L->getNumBlocks() > 4)
return;
// Scan the loop: don't unroll loops with calls as this could prevent
// inlining.
unsigned Cost = 0;
for (auto *BB : L->getBlocks()) {
for (auto &I : *BB) {
// Don't unroll vectorised loop. MVE does not benefit from it as much as
// scalar code.
if (I.getType()->isVectorTy())
return;
if (isa<CallInst>(I) || isa<InvokeInst>(I)) {
ImmutableCallSite CS(&I);
if (const Function *F = CS.getCalledFunction()) {
if (!isLoweredToCall(F))
continue;
}
return;
}
SmallVector<const Value*, 4> Operands(I.value_op_begin(),
I.value_op_end());
Cost += getUserCost(&I, Operands);
}
}
LLVM_DEBUG(dbgs() << "Cost of loop: " << Cost << "\n");
UP.Partial = true;
UP.Runtime = true;
UP.UpperBound = true;
UP.UnrollRemainder = true;
UP.DefaultUnrollRuntimeCount = 4;
UP.UnrollAndJam = true;
UP.UnrollAndJamInnerLoopThreshold = 60;
// Force unrolling small loops can be very useful because of the branch
// taken cost of the backedge.
if (Cost < 12)
UP.Force = true;
}
bool ARMTTIImpl::useReductionIntrinsic(unsigned Opcode, Type *Ty,
TTI::ReductionFlags Flags) const {
assert(isa<VectorType>(Ty) && "Expected Ty to be a vector type");
unsigned ScalarBits = Ty->getScalarSizeInBits();
if (!ST->hasMVEIntegerOps())
return false;
switch (Opcode) {
case Instruction::FAdd:
case Instruction::FMul:
case Instruction::And:
case Instruction::Or:
case Instruction::Xor:
case Instruction::Mul:
case Instruction::FCmp:
return false;
case Instruction::ICmp:
case Instruction::Add:
return ScalarBits < 64 &&
(ScalarBits * Ty->getVectorNumElements()) % 128 == 0;
default:
llvm_unreachable("Unhandled reduction opcode");
}
return false;
}
|
mov ax, 0xb800
mov es, ax
and di, 0
; Century
mov al, 0x32
out 0x70, al
in al, 0x71
call read_CMOS_disp
; Year
mov al, 0x9
out 0x70, al
in al, 0x71
call read_CMOS_disp
call print_dash
; Month
mov al, 0x8
out 0x70, al
in al, 0x71
call read_CMOS_disp
call print_dash
; Day
mov al, 0x7
out 0x70, al
in al, 0x71
call read_CMOS_disp
jmp $
read_CMOS_disp:
and ah, 0
push dx
mov dl, al
and dl, 0xf
add dl, 0x30
shr al, 4
add al, 0x30
mov [es:di], al
inc di
mov byte [es:di], 0x07
inc di
mov [es:di], dl
inc di
mov byte [es:di], 0x07
inc di
pop dx
ret
print_dash:
mov byte [es:di], 0x2d
inc di
mov byte [es:di], 0x07
inc di
ret
times 510 - ($ - $$) db 0
dw 0xAA55
|
org $02b5c4 ; -- moving right routine 135c4
jsl WarpRight
org $02b665 ; -- moving left routine
jsl WarpLeft
org $02b713 ; -- moving down routine
jsl WarpDown
org $02b7b4 ; -- moving up routine
jsl WarpUp
org $02bd80
jsl AdjustTransition
nop
;turn off linking doors -- see .notRoomLinkDoor label in Bank02.asm
org $02b5a6
bra NotLinkDoor1
org $02b5b6
NotLinkDoor1:
org $02b647
bra NotLinkDoor2
org $02b657
NotLinkDoor2:
; Staircase routine
org $01c3d4 ;(PC: c3d4)
jsl RecordStairType : nop
org $02a1e7 ;(PC: 121e7)
jsl SpiralWarp
; Graphics fix
org $02895d
Splicer:
jsl GfxFixer
lda $b1 : beq .done
rts
nop #5
.done
org $00fda4
Dungeon_InitStarTileCh:
org $00d6ae ;(PC: 56ae)
LoadTransAuxGfx:
org $00df5a ;(PC: 5f5a)
PrepTransAuxGfx:
org $0ffd65 ;(PC: 07fd65)
Dungeon_LoadCustomTileAttr:
;org $01fec1
;Dungeon_ApproachFixedColor_variable:
;org $a0f972 ; Rando version
;LoadRoomHook:
org $1bee74 ;(PC: 0dee74)
Palette_DungBgMain:
org $1bec77
Palette_SpriteAux3:
org $1becc5
Palette_SpriteAux2:
org $1bece4
Palette_SpriteAux1:
org $0DFA53
jsl.l LampCheckOverride
org $028046 ; <- 10046 - Bank02.asm : 217 (JSL EnableForceBlank) (Start of Module_LoadFile)
jsl.l OnFileLoadOverride
org $05ef47
Sprite_HeartContainer_Override: ;sprite_heart_upgrades.asm : 96-100 (LDA $040C : CMP.b #$1A : BNE .not_in_ganons_tower)
jsl GtBossHeartCheckOverride : bcs .not_in_ganons_tower
nop : stz $0dd0, X : rts
.not_in_ganons_tower
; These two, if enabled together, have implications for vanilla BK doors in IP/Hera/Mire
; IPBJ is common enough to consider not doing this. Mire is not a concern for vanilla - maybe glitched modes
; Hera BK door back can be seen with Pot clipping - likely useful for no logic seeds
;Kill big key (1e) check for south doors
;org $1aa90
;DontCheck:
;bra .done
;nop #3
;.done
;Enable south facing bk graphic
;org $4e24
;dw $2ac8
org $01b714 ; PC: b714
OpenableDoors:
jsl CheckIfDoorsOpen
bcs .normal
rts
.normal
|
; void sms_tiles_clear_area(struct r_Rect8 *r, unsigned int background)
;
; Clear the rectangular area on screen
SECTION code_clib
SECTION code_arch
PUBLIC asm_sms_tiles_clear_area
EXTERN asm_sms_cls_wc
defc asm_sms_tiles_clear_area = asm_sms_cls_wc
; enter : hl = background character
; ix = rect *
;
; uses : af, bc, de, hl
|
;;
;; Copyright (c) Microsoft Corporation. All rights reserved.
;;
;;;;;;;;;;;;;;;;;;;;
; Concerns
; 1 - there is no error checking on the int13 calls
; 2 - we assume that the block size is 2048 bytes
; 3 - this cannot handle large root directories (>64KB)
;;;;;;;;;;;;;;;;;;;;
; Constants
BootSecOrigin EQU 07c00h ; the BIOS puts the boot sector at 07c0h:0000 == 0000:7c00h
StackOffset EQU -12 ; we will put the stack a small bit below it (we hardly use the stack, so it is safe...)
;;;;;;;;;;;;;;;;;;;;
; Macros
JMPF16 MACRO SEG:REQ,OFF:REQ
db 0eah
dw OFF
dw SEG
ENDM
;;;;;;;;;;;;;;;;;;;;
; Directives
.model tiny
.686p
;;;;;;;;;;;;;;;;;;;;
; Begin Code segment
_TEXT SEGMENT use16 ; 16-bit code segment
.code
ORG 0h ; ETFS puts us at 07c0h:0000
start:
JMPF16 07c0h,OFFSET Step1
Step1: ; set stack and data segments
mov cx, cs
mov ss, cx
mov sp, BootSecOrigin + StackOffset
mov es, cx
mov ds, cx
mov bp, sp
Step2: ; Save the boot drive (dl holds it on boot)
mov [CDDrive], dl
Step3: ; Clear the Screen
mov ax, 02h
int 010h
;; Configure GS to point to the text-mode video console.
mov ax, 0b800h
mov gs, ax
;; Write 'A' to position 0.
mov ax, 04f41h
mov gs:[0], ax
;; Write 'B' to position 1.
mov ax, 04f42h
mov gs:[2], ax
Step4: ; Load the PVD to get the Logical Block Size
mov eax, 10h ; the PVD is in the 16th block
mov bx, 2000h
mov es, bx ; transfer address = 2000:0000
mov cx, 1
call ReadDisk
mov ax, es:128 ; block size is at offset 128
mov [BlockSize], ax
;; Write 'C' to position 2.
mov ax, 04f43h
mov gs:[4], ax
Step5: ; Find the Joliet SVD, and then find the Root Directory Information
mov eax, 10h ; start with the PVD, even though it will fail
GetNextVD:
push eax
mov cx, 1
call ReadDisk
mov si, OFFSET SVDesc ; [ds:si] points to the desired first 6 bytes of this VD
xor di, di ; [es:di] points to the start of what we just read
mov cx, 6
repe cmpsb
je FoundSVD
mov al, es:0000h
cmp al, 0FFh ; is this the last Volume Descriptor?
je SVDError
pop eax
inc eax
jmp GetNextVD ; try another VD
FoundSVD: ; need to make sure this is a Joliet SVD - we need 025h, 02Fh, 045h in [88,89,90]
mov si, OFFSET JolietSig ; [ds:si] points to the Joliet Signature
mov di, 88 ; [es:di] points to the escape sequence field of the current SVD
mov cx, 3
repe cmpsb
je FoundJoliet
pop eax
inc eax
jmp GetNextVD
FoundJoliet:
;; Write 'D' to position 3.
mov ax, 04f44h
mov gs:[6], ax
mov eax, es:158 ; now get the rootstart and rootsize fields
mov [RootStart], eax
mov eax, es:166
mov [RootSize], eax
Step6: ; Load the Root Directory (SVD), and search it for SINGLDR
movzx ebx, [BlockSize]
div ebx ; eax has # blocks in root directory. Round up if necessary:
cmp edx, 0
je ReadyToLoad
add eax, 1
ReadyToLoad: ; we're going to assume that the root directory will not be bigger than 64K
mov ecx, eax
mov eax, [RootStart]
call ReadDisk
xor ebx, ebx ; bx will hold the start of the current entry
CheckEntry:
mov di, bx
add di, 25 ; let's check the file flags - should be 00
mov al, es:[di]
cmp al, 0
jne PrepNextEntry
; file flags are good. now check the file identifier:
mov si, OFFSET Stage2FileSize
xor cx, cx
mov cl, ds:[si] ; first byte is file name length
add cx, 2 ; add two because we check the length byte of the directory entry and the padding byte, too
add di, 7 ; now es:di points to the file length/name field, and ds:si has our desired content
repe cmpsb
je FoundEntry
PrepNextEntry:
xor cx, cx ; increment bx by adding the byte value in es:[bx]
mov cl, es:[bx] ; if es:[bx]==0 and ebx!= [RootSize], then we are in a padding zone
cmp cx, 0 ; designed to prevent a directory entry from spilling over a block.
jne LoadNext ; Should this be the case, we will increment bx until es:[bx] is not null
inc bx
jmp PrepNextEntry
LoadNext:
add bx, cx
cmp ebx, [RootSize]
jl CheckEntry
jmp FileNotFoundError
FoundEntry:
;; Write 'E' to position 5.
mov ax, 04f45h
mov gs:[8], ax
mov eax, es:[bx+2]
mov [FileStart], eax
mov eax, es:[bx+10]
mov [FileSize], eax
Step7: ; Load the file to 57c0:0000
mov cx, 057c0h
mov es, cx
movzx ebx, [BlockSize]
div ebx ; eax has # blocks in root directory
cmp edx, 0 ; on carry, there will be one more block
je ReadyToLoadFile
add eax, 1
ReadyToLoadFile:
mov ecx, eax
mov eax, [FileStart]
call ReadDisk
;; Write 'F' to position 6.
mov ax, 04f46h
mov gs:[10], ax
Step8: ; Now we need to set up the stack for SINGLDR and do a jump
xor cx, cx ; Always point the stack to 0000:7c00h - 12
mov ss, cx
mov sp, BootSecOrigin + StackOffset
movzx edx, [CDDrive]
push edx ; SINGLDR will need to know the boot drive #
pushd 04344h ; CD boot signature
pushw offset infloop ; return address = "infloop", which is the infinite loop
push cs
;; Write 'G' to position 7.
mov ax, 04f47h
mov gs:[12], ax
db 0EAh ; emit a long jump to 5000:7c00
dd 50007c00h
;;;;;;;;;;;;;;;;;;;;
; ReadDisk
;
; Inputs: eax = Block Number
; cx = number of blocks to read (warning: cx > 32 will cause overflow)
; es = destination segment
; Assumptions: 1 - assumes request will not cause overflow of es:00 (limit on # sectors)
; 2 - assumes int13 extensions available
ReadDisk PROC NEAR
pushad
mov dl, [CDDrive] ; set the drive
pushd 00
push eax ; push 64-bit block number (top half always null)
push es
pushw 00h ; push transfer address
push cx ; # sectors
pushw 0010h ; this request packet is 16 bytes
mov ah,42h ; extended read
mov si,sp ; ds:si = address of params
int 13h ; perform the read
add sp, 10h ; clean the stack and return
popad
ret
ReadDisk ENDP
;;;;;;;;;;;;;;;;;;;;
; Error Routines (these are jump points that never return)
SVDError:
mov si, offset SvdFailMsg
call PrintString
@@:
jmp @b
FileNotFoundError:
mov si, offset FileNotFoundMsg
call PrintString
@@:
jmp @b
PrintString:
psnext:
lodsb
or al, al
jz done
;;; Write directly to memory.
mov ah, 047h
mov bx, [Cursor]
mov gs:[bx], ax
add bx, 2
mov [Cursor], bx
mov bx, 07h ; normal attribute
mov ah, 0eh ; default print 1 char
int 10h
jmp psnext
done:
ret
infloop:
jmp infloop
;;;;;;;;;;;;;;;;;;;;
; Global Vars
RootStart DD 0
RootSize DD 0
CDDrive DB 0
BlockSize DW 0
FileStart DD 0
FileSize DD 0
Cursor DW 640
;;;;;;;;;;;;;;;;;;;;
; String Constants
SVDesc DB 02h, "CD001"
JolietSig DB 25h, 2fh, 45h ; this is the value of the escape sequence for a Joliet CD
; we'll use it as the signature...
Stage2FileSize DB OFFSET Stage2FilePad - OFFSET Stage2File
Stage2File DB 0,"S",0,"i",0,"n",0,"g",0,"l",0,"d",0,"r" ; in unicode, this is how our filename will appear
Stage2FilePad DB 0
SvdFailMsg DB 10,13,"SVD Failed",0
FileNotFoundMsg DB 10,13,"File not found",0
;;;;;;;;;;;;;;;;;;;;
; Boot Sector Signature
ORG 510
DW 0AA55h
end start
|
.global s_prepare_buffers
s_prepare_buffers:
push %r13
push %r15
push %rbp
push %rbx
push %rcx
push %rdi
push %rsi
lea addresses_D_ht+0x1892d, %rsi
nop
nop
and %rbx, %rbx
mov (%rsi), %ecx
nop
nop
sub $27389, %r15
lea addresses_WT_ht+0x1492d, %rsi
nop
nop
nop
nop
nop
xor %r13, %r13
movb $0x61, (%rsi)
nop
nop
nop
nop
nop
inc %rcx
lea addresses_normal_ht+0x1492d, %r15
nop
nop
nop
nop
and %rbp, %rbp
mov (%r15), %si
nop
nop
sub %rdi, %rdi
lea addresses_WC_ht+0x1ffd, %r13
clflush (%r13)
nop
nop
sub %r15, %r15
mov (%r13), %rcx
sub $6040, %r15
lea addresses_D_ht+0x686d, %r13
clflush (%r13)
nop
nop
nop
nop
dec %rsi
mov $0x6162636465666768, %rbp
movq %rbp, %xmm1
movups %xmm1, (%r13)
nop
nop
nop
nop
dec %rsi
lea addresses_normal_ht+0x1eacd, %rbp
nop
nop
nop
nop
nop
xor $17591, %rcx
movups (%rbp), %xmm6
vpextrq $0, %xmm6, %r13
nop
nop
cmp %r13, %r13
lea addresses_D_ht+0x1a7ad, %r13
nop
nop
nop
nop
sub $3777, %r15
mov $0x6162636465666768, %rbx
movq %rbx, %xmm7
movups %xmm7, (%r13)
nop
cmp %rbp, %rbp
lea addresses_WT_ht+0x1b2d, %r13
dec %rsi
mov $0x6162636465666768, %rbx
movq %rbx, (%r13)
nop
nop
nop
nop
cmp %rbp, %rbp
lea addresses_normal_ht+0x1cbad, %rbx
and $19443, %rdi
movb $0x61, (%rbx)
nop
nop
nop
nop
xor %rcx, %rcx
lea addresses_D_ht+0x17f12, %rsi
nop
nop
sub %r13, %r13
movl $0x61626364, (%rsi)
nop
dec %r13
lea addresses_UC_ht+0x16f53, %rbp
nop
nop
nop
sub %rbx, %rbx
and $0xffffffffffffffc0, %rbp
vmovntdqa (%rbp), %ymm1
vextracti128 $0, %ymm1, %xmm1
vpextrq $0, %xmm1, %rcx
nop
add $63857, %rcx
lea addresses_UC_ht+0x6995, %rsi
nop
nop
nop
nop
sub $21229, %rcx
movb (%rsi), %r13b
sub %rsi, %rsi
pop %rsi
pop %rdi
pop %rcx
pop %rbx
pop %rbp
pop %r15
pop %r13
ret
.global s_faulty_load
s_faulty_load:
push %r10
push %r12
push %r14
push %rcx
push %rdx
// Faulty Load
lea addresses_A+0x892d, %rcx
nop
nop
nop
dec %r12
vmovaps (%rcx), %ymm1
vextracti128 $1, %ymm1, %xmm1
vpextrq $0, %xmm1, %r10
lea oracles, %rdx
and $0xff, %r10
shlq $12, %r10
mov (%rdx,%r10,1), %r10
pop %rdx
pop %rcx
pop %r14
pop %r12
pop %r10
ret
/*
<gen_faulty_load>
[REF]
{'src': {'type': 'addresses_A', 'same': False, 'size': 32, 'congruent': 0, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'}
[Faulty Load]
{'src': {'type': 'addresses_A', 'same': True, 'size': 32, 'congruent': 0, 'NT': False, 'AVXalign': True}, 'OP': 'LOAD'}
<gen_prepare_buffer>
{'src': {'type': 'addresses_D_ht', 'same': False, 'size': 4, 'congruent': 10, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'}
{'dst': {'type': 'addresses_WT_ht', 'same': False, 'size': 1, 'congruent': 6, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'}
{'src': {'type': 'addresses_normal_ht', 'same': False, 'size': 2, 'congruent': 11, 'NT': False, 'AVXalign': True}, 'OP': 'LOAD'}
{'src': {'type': 'addresses_WC_ht', 'same': False, 'size': 8, 'congruent': 3, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'}
{'dst': {'type': 'addresses_D_ht', 'same': False, 'size': 16, 'congruent': 5, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'}
{'src': {'type': 'addresses_normal_ht', 'same': False, 'size': 16, 'congruent': 4, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'}
{'dst': {'type': 'addresses_D_ht', 'same': False, 'size': 16, 'congruent': 7, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'}
{'dst': {'type': 'addresses_WT_ht', 'same': False, 'size': 8, 'congruent': 9, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'}
{'dst': {'type': 'addresses_normal_ht', 'same': False, 'size': 1, 'congruent': 6, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'}
{'dst': {'type': 'addresses_D_ht', 'same': False, 'size': 4, 'congruent': 0, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'}
{'src': {'type': 'addresses_UC_ht', 'same': False, 'size': 32, 'congruent': 1, 'NT': True, 'AVXalign': False}, 'OP': 'LOAD'}
{'src': {'type': 'addresses_UC_ht', 'same': False, 'size': 1, 'congruent': 3, 'NT': True, 'AVXalign': False}, 'OP': 'LOAD'}
{'e6': 1, 'e5': 1, 'bf': 1, 'ab': 1, '1e': 2, '09': 1, '77': 1, '4e': 1, '80': 1, '75': 1, 'be': 2, '47': 2370, 'dc': 1, '8b': 1, 'ce': 1, 'b9': 1, 'c5': 1, '04': 1, '16': 12992, '9c': 2, 'bc': 1, 'ae': 1, 'fe': 1, 'ee': 2, '28': 2, '14': 1, 'f0': 1, 'a6': 1, '94': 1, '6e': 1, 'ea': 1, '60': 339, 'a2': 1, '5c': 2, '82': 1, '12': 1, 'ac': 1, '17': 1, '34': 1, 'd2': 1, '57': 1, 'b4': 1, '2a': 1, '4c': 2, 'a8': 2, 'fa': 1, 'da': 2, '2c': 1, 'ec': 1, 'f8': 3, 'd4': 1, '9e': 1, '31': 1, 'cc': 2, '0c': 4, '08': 1, '3c': 1, '24': 2, 'f4': 2, '58': 1, 'bb': 1, 'b2': 2, '26': 1, '74': 2, '84': 4, '0a': 2, '30': 1, 'c4': 1, '90': 2, '88': 1, '8e': 1, '6f': 1, '7e': 1, '40': 1, '01': 1, 'e0': 1, '7d': 1, '02': 1, 'd0': 1, '00': 6010, '10': 1, 'c0': 1, '96': 1, 'aa': 1, '9d': 1, '72': 1, 'f7': 1, '56': 1, '59': 1, 'a4': 1, '86': 2, '70': 2, 'e8': 2, 'a0': 1, 'c9': 1}
00 00 00 16 47 16 16 00 00 16 00 16 16 16 16 16 60 47 00 16 00 00 00 00 16 16 16 16 16 00 47 16 00 00 47 16 00 16 16 16 16 47 16 16 16 16 16 16 16 16 16 16 00 16 00 60 16 16 16 16 16 16 00 16 16 16 16 16 16 16 00 16 16 16 60 16 16 16 16 60 00 16 16 16 16 16 16 00 16 16 16 00 16 16 00 16 16 16 16 16 00 16 9c 16 47 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 00 16 16 47 00 16 16 16 16 16 16 47 16 16 16 16 00 16 16 16 16 16 16 16 00 16 16 16 16 16 16 16 00 16 16 16 16 47 16 16 60 00 16 00 16 16 60 16 16 70 16 16 16 00 16 16 16 00 16 16 16 16 16 16 16 16 47 16 16 16 0c 16 00 16 16 16 00 16 16 16 16 16 00 47 16 16 16 16 16 16 16 16 00 16 16 00 00 16 16 00 16 00 16 16 16 16 16 16 47 16 16 16 16 16 00 00 16 16 16 16 16 16 16 16 16 00 16 16 47 16 16 16 60 47 16 16 00 16 16 00 47 47 00 16 00 00 60 16 00 16 00 47 60 47 47 47 00 47 00 16 16 00 16 16 16 16 47 16 16 16 16 16 00 47 16 47 16 16 16 16 16 00 16 16 16 16 16 16 16 16 00 16 00 00 16 16 00 16 16 16 16 16 16 00 16 16 16 16 16 16 16 16 00 00 00 00 16 16 16 16 16 16 16 16 00 16 16 16 16 16 00 47 16 16 00 00 16 47 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 00 00 00 16 16 47 16 16 16 00 16 16 16 16 16 16 16 00 16 16 16 16 16 88 00 47 16 16 16 16 16 16 16 16 16 00 16 16 16 00 16 16 16 16 00 16 00 16 00 16 16 00 00 00 16 00 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 00 16 16 16 16 16 16 16 16 16 16 16 16 00 00 16 16 16 16 16 16 16 16 16 16 00 00 16 00 16 00 16 47 60 16 16 16 16 16 16 00 16 16 16 16 47 16 16 16 16 00 16 16 16 16 16 16 16 16 16 47 00 16 16 16 16 16 16 16 16 16 00 60 16 00 00 94 00 16 00 16 00 00 00 47 47 16 16 16 47 00 16 16 16 16 00 16 16 47 00 16 16 16 16 00 16 16 16 16 00 16 16 00 47 16 16 16 16 16 00 16 16 16 16 16 16 00 16 16 16 16 16 16 16 16 16 16 16 16 00 16 16 16 16 16 16 00 00 47 16 16 47 47 16 16 00 00 00 16 16 16 16 16 16 16 16 16 00 16 00 00 00 16 16 16 00 00 16 16 16 16 00 16 16 16 16 16 16 16 16 16 16 00 16 00 47 16 00 16 16 16 16 16 16 16 16 16 00 16 16 16 00 00 16 16 16 16 16 00 16 00 3c 16 00 47 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 00 00 00 16 00 00 00 16 16 16 00 16 16 16 16 16 00 00 00 00 16 16 16 00 00 00 16 16 16 16 16 16 16 16 16 16 16 16 60 00 16 16 16 16 16 16 47 00 16 16 00 10 16 00 16 16 16 16 16 16 16 16 16 16 16 16 16 00 16 16 16 16 16 00 00 00 00 16 16 16 16 16 16 16 00 47 16 16 16 16 16 16 16 16 00 47 16 16 00 00 16 16 16 16 16 00 16 16 16 16 16 16 16 16 00 16 00 16 16 16 16 16 16 16 16 16 16 16 47 16 16 16 16 16 16 16 16 16 47 16 00 00 16 16 16 16 16 16 16 16 00 16 00 16 16 16 47 00 16 16 47 16 00 00 16 16 16 16 16 00 16 00 16 16 16 47 16 16 16 16 00 00 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 47 16 16 16 16 16 16 16 16 16 00 00 16 16 16 00 16 00 00 16 16 00 00 47 16 16 16 16 16 16 16 16 16 16 00 00 00 47 00 16 00 16 16 16 00 16 16 00 00 16 47 16 00 47 00 16 16 00 16 16 16 00 16 00 16 16 16 00 16 16 16 00 00 00 16 47 47 16 16 16 16 16 16 16 16 16 16 16 00 16 47 00 00 00 16 16 16 16 00 16 16 16 16 16 16 16 16
*/
|
;--------------------------------------------------------------
; ZX81 HRG library for the G007 expansion
; by Stefano Bodrato, Fall 2014
;--------------------------------------------------------------
;
; Set HRG mode and clear screen
;
; $Id: g007_clg_hr.asm,v 1.4 2015/01/19 01:32:52 pauloscustodio Exp $
;
PUBLIC _clg_hr
EXTERN hrg_on
; XREF base_graphics
; XREF G007_P2
._clg_hr
jp hrg_on
;; if hrgpage has not been specified, then set a default value
; ld hl,(base_graphics)
; ld a,h
; or l
; jr nz,gotpage
; ld hl,24600 ; on a 16K system we leave a space of a bit more than 1500 bytes for stack
; ld (base_graphics),hl
;gotpage:
;
; ld hl,(base_graphics)
; ld de,9
; add hl,de
;
; ld a,$76 ; NEWLINE (HALT in machine code)
; ld (hl),a
; inc hl
; ld (hl),a
; inc hl
;
;
; ld (hl),0
; ld d,h
; ld e,l
; inc de
; ld bc,34*192+4
; ldir
;
; ld (hl),a ; NEWLINE (HALT in machine code)
; inc hl
; ld (hl),a
;
; ld a,(G007_P2+2)
; cp 193
; jp nz,hrg_on
;
; ret
|
db KAKUNA ; 014
db 45, 25, 50, 35, 25, 25
; hp atk def spd sat sdf
db BUG, POISON ; type
db 120 ; catch rate
db 71 ; base exp
db NO_ITEM, NO_ITEM ; items
db GENDER_F50 ; gender ratio
db 100 ; unknown 1
db 15 ; step cycles to hatch
db 5 ; unknown 2
INCBIN "gfx/pokemon/kakuna/front.dimensions"
db 0, 0, 0, 0 ; padding
db GROWTH_MEDIUM_FAST ; growth rate
dn EGG_BUG, EGG_BUG ; egg groups
; tm/hm learnset
tmhm
; end
|
; A178460: Partial sums of floor(2^n/127).
; 0,0,0,0,0,0,1,3,7,15,31,63,127,256,514,1030,2062,4126,8254,16510,33023,66049,132101,264205,528413,1056829,2113661,4227326,8454656,16909316,33818636,67637276,135274556,270549116,541098237,1082196479,2164392963,4328785931,8657571867,17315143739,34630287483,69260574972,138521149950,277042299906,554084599818,1108169199642,2216338399290,4432676798586,8865353597179,17730707194365,35461414388737,70922828777481,141845657554969,283691315109945,567382630219897,1134765260439802,2269530520879612
mov $4,$0
mov $5,$0
lpb $5
mov $0,$4
sub $5,1
sub $0,$5
sub $0,1
mov $2,4
lpb $0
sub $0,1
mul $2,2
lpe
mov $3,$2
div $3,127
add $1,$3
lpe
mov $0,$1
|
_SaffronHouse1Text1::
text "Thank you for"
line "writing. I hope"
cont "to see you soon!"
para "Hey! Don't look"
line "at my letter!"
done
_SaffronHouse1Text2::
text "PIDGEY: Kurukkoo!@@"
_SaffronHouse1Text3::
text "The COPYCAT is"
line "cute! I'm getting"
cont "her a # DOLL!"
done
_SaffronHouse1Text4::
text "I was given a PP"
line "UP as a gift."
para "It's used for"
line "increasing the PP"
cont "of techniques!"
done
|
; A170146: Number of reduced words of length n in Coxeter group on 41 generators S_i with relations (S_i)^2 = (S_i S_j)^38 = I.
; 1,41,1640,65600,2624000,104960000,4198400000,167936000000,6717440000000,268697600000000,10747904000000000,429916160000000000,17196646400000000000,687865856000000000000,27514634240000000000000
add $0,1
mov $3,1
lpb $0
sub $0,1
add $2,$3
div $3,$2
mul $2,40
lpe
mov $0,$2
div $0,40
|
; /************************ ZW_PATCHTABLE_FOOTER.A51 ************************
; * #######
; * ## ##
; * # ## #### ##### ##### ## ## #####
; * ## ## ## ## ## ## ## ## ##
; * ## # ###### ## ## #### ## ## ####
; * ## ## ## ## ## ## ##### ##
; * ####### #### ## ## ##### ## #####
; * #####
; * Z-Wave, the wireless language.
; *
; * Copyright (c) 2001
; * Zensys A/S
; * Denmark
; *
; * All Rights Reserved
; *
; * This source file is subject to the terms and conditions of the
; * Zensys Software License Agreement which restricts the manner
; * in which it may be used.
; *
; *---------------------------------------------------------------------------
; *
; * Description: Z-Wave tableOfPatchedFunctions:
; * This table contains a NULL terminated list of pointer pairs for the
; * functions in ROM, for which we have a patch.
; * The table is immediatly followed by a footer of a fixed format and
; * which shall be located at a fixed address in the top of memory.
; *
; * This module contains the footer for the tableOfPatchedFunctions,
; * and it has to be linked in as the very last module during linking
; * of the program under development, and to be loaded in executable RAM.
; * Linking in this footer after anything else assures that every entry
; * for the patchTable generated by the program compilation will be included
; * in the final patchTable during linking.
; *
; * Author: Erik Friis Harck
; *
; * Last Changed By: $Author: efh $
; * Revision: $Revision: 9763 $
; * Last Changed: $Date: 2008-01-10 11:28:42 +0100 (Thu, 10 Jan 2008) $
; *
; ****************************************************************************/
;
$NOMOD51
NAME ZW_PATCHTABLE_FOOTER
?CO?ZW_PATCHTABLE SEGMENT CODE
PUBLIC patchTableFooter
; /****************************************************************************/
; /* PRIVATE TYPES and DEFINITIONS */
; /****************************************************************************/
;
; typedef void (code * functionPointer)();
;
; typedef struct {
; functionPointer originalFunction;
; functionPointer patchFunction;
; } tsPatchTableEntry;
;
; /****************************************************************************/
; /* EXPORTED DATA */
; /****************************************************************************/
;
; code tsPatchTableEntry tableOfPatchedFunctions[] = {
; {Return_EnQueueSingleData, Continue_EnQueueSingleData},
; .
; .
; .
; {NULL, NULL} /* Terminate the table with a NULL */
; };
; code tsPatchTableEntry patchTableFooter[] = {
; /* The last entry shall contain a pointer to the start of this table */
; /* and a checksum */
; {tableOfPatchedFunctions, NULL}
; };
;
RSEG ?CO?ZW_PATCHTABLE
;/* Start with the function with the highest address, */
;/* and end with the function with the lowest address */
;;tableOfPatchedFunctions:
#ifdef ZW030x
;; EXTRN CODE (_?Return_ApplicationRfNotify,_?Continue_ApplicationRfNotify)
;; DW _?Return_ApplicationRfNotify,_?Continue_ApplicationRfNotify
#endif
;; EXTRN CODE (_?Return_ApplicationInitHW,_?Continue_ApplicationInitHW)
;; DW _?Return_ApplicationInitHW,_?Continue_ApplicationInitHW
;; EXTRN CODE (_?Return_ApplicationInitSW,_?Continue_ApplicationInitSW)
;; DW _?Return_ApplicationInitSW,_?Continue_ApplicationInitSW
;; EXTRN CODE (_?Return_ApplicationTestPoll,_?Continue_ApplicationTestPoll)
;; DW _?Return_ApplicationTestPoll,_?Continue_ApplicationTestPoll
;; EXTRN CODE (_?Return_ApplicationPoll,_?Continue_ApplicationPoll)
;; DW _?Return_ApplicationPoll,_?Continue_ApplicationPoll
;; EXTRN CODE (_?Return_ApplicationCommandHandler,_?Continue_ApplicationCommandHandler)
;; DW _?Return_ApplicationCommandHandler,_?Continue_ApplicationCommandHandler
;; EXTRN CODE (_?Return_ApplicationSlaveUpdate,_?Continue_ApplicationSlaveUpdate)
;; DW _?Return_ApplicationSlaveUpdate,_?Continue_ApplicationSlaveUpdate
;; EXTRN CODE (_?Return_ApplicationNodeInformation,_?Continue_ApplicationNodeInformation)
;; DW _?Return_ApplicationNodeInformation,_?Continue_ApplicationNodeInformation
; EXTRN CODE (_?Return_EnQueueSingleData, _?Continue_EnQueueSingleData)
; DW _?Return_EnQueueSingleData + 0,_?Continue_EnQueueSingleData + 0
DW 00000H,00000H ;/* Terminate the table with a NULL */
EXTRN CODE (tableOfPatchedFunctions)
patchTableFooter:
DW tableOfPatchedFunctions,00000H
END
|
; Hello World Program (External file include)
; Compile with: nasm -f elf helloworld-inc.asm
; Link with (64 bit systems require elf_i386 option): ld -m elf_i386 helloworld-inc.o -o helloworld-inc
; Run with: ./helloworld-inc
%include 'functions.asm' ; include our external file
SECTION .data
msg1 db 'Hello, brave new world!', 0Ah ; our first message string
msg2 db 'This is how we recycle in NASM.', 0Ah ; our second message string
SECTION .text
global _start
_start:
mov eax, msg1 ; move the address of our first message string into EAX
call sprint ; call our string printing function
mov eax, msg2 ; move the address of our second message string into EAX
call sprint ; call our string printing function
call quit ; call our quit function |
addi x9, x0, 9
addi x10, x0, 10
add x20, x0, x0 # x20 = 0
add x11, x0, x0 # x11 = 0
addi x12, x0, 5 # x12 = 5
addi x13, x0, 24 # x13 = 24
addi x24, x0, 1 # x24 = 1
j function1
function1:
beq x11, x12, function2 #vai dar o branch para a label "function2" quando x11 == 5
addi x20, x20, 100
# o conteudo de x20 fica igual a x9 + x10 = 19
addi x11, x11, 1
j function1
function2:
sub x13, x13, x24
|
; A158640: 52*n^2 - 1.
; 51,207,467,831,1299,1871,2547,3327,4211,5199,6291,7487,8787,10191,11699,13311,15027,16847,18771,20799,22931,25167,27507,29951,32499,35151,37907,40767,43731,46799,49971,53247,56627,60111,63699,67391,71187,75087,79091,83199,87411,91727,96147,100671,105299,110031,114867,119807,124851,129999,135251,140607,146067,151631,157299,163071,168947,174927,181011,187199,193491,199887,206387,212991,219699,226511,233427,240447,247571,254799,262131,269567,277107,284751,292499,300351,308307,316367,324531,332799
mov $1,2
add $1,$0
mul $1,$0
mul $1,52
add $1,51
mov $0,$1
|
// Copyright (c) 2014-2017 The Dash Core developers
// Copyright (c) 2017-2018 The BitcoinNode Core developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
//#define ENABLE_BTN_DEBUG
#include "activemasternode.h"
#include "darksend.h"
#include "governance.h"
#include "governance-vote.h"
#include "governance-classes.h"
#include "init.h"
#include "main.h"
#include "masternode.h"
#include "masternode-sync.h"
#include "masternodeconfig.h"
#include "masternodeman.h"
#include "rpcserver.h"
#include "util.h"
#include "utilmoneystr.h"
#include <boost/lexical_cast.hpp>
UniValue gobject(const UniValue& params, bool fHelp)
{
std::string strCommand;
if (params.size() >= 1)
strCommand = params[0].get_str();
if (fHelp ||
(strCommand != "vote-many" && strCommand != "vote-conf" && strCommand != "vote-alias" && strCommand != "prepare" && strCommand != "submit" && strCommand != "count" &&
strCommand != "deserialize" && strCommand != "get" && strCommand != "getvotes" && strCommand != "getcurrentvotes" && strCommand != "list" && strCommand != "diff"))
throw std::runtime_error(
"gobject \"command\"...\n"
"Manage governance objects\n"
"\nAvailable commands:\n"
" prepare - Prepare governance object by signing and creating tx\n"
" submit - Submit governance object to network\n"
" deserialize - Deserialize governance object from hex string to JSON\n"
" count - Count governance objects and votes\n"
" get - Get governance object by hash\n"
" getvotes - Get all votes for a governance object hash (including old votes)\n"
" getcurrentvotes - Get only current (tallying) votes for a governance object hash (does not include old votes)\n"
" list - List governance objects (can be filtered by validity and/or object type)\n"
" diff - List differences since last diff\n"
" vote-alias - Vote on a governance object by masternode alias (using masternode.conf setup)\n"
" vote-conf - Vote on a governance object by masternode configured in bitcoinnode.conf\n"
" vote-many - Vote on a governance object by all masternodes (using masternode.conf setup)\n"
);
if(strCommand == "count")
return governance.ToString();
/*
------ Example Governance Item ------
gobject submit 6e622bb41bad1fb18e7f23ae96770aeb33129e18bd9efe790522488e580a0a03 0 1 1464292854 "beer-reimbursement" 5b5b22636f6e7472616374222c207b2270726f6a6563745f6e616d65223a20225c22626565722d7265696d62757273656d656e745c22222c20227061796d656e745f61646472657373223a20225c225879324c4b4a4a64655178657948726e34744744514238626a6876464564615576375c22222c2022656e645f64617465223a202231343936333030343030222c20226465736372697074696f6e5f75726c223a20225c227777772e646173687768616c652e6f72672f702f626565722d7265696d62757273656d656e745c22222c2022636f6e74726163745f75726c223a20225c22626565722d7265696d62757273656d656e742e636f6d2f3030312e7064665c22222c20227061796d656e745f616d6f756e74223a20223233342e323334323232222c2022676f7665726e616e63655f6f626a6563745f6964223a2037342c202273746172745f64617465223a202231343833323534303030227d5d5d1
*/
// DEBUG : TEST DESERIALIZATION OF GOVERNANCE META DATA
if(strCommand == "deserialize")
{
if (params.size() != 2) {
throw JSONRPCError(RPC_INVALID_PARAMETER, "Correct usage is 'gobject deserialize <data-hex>'");
}
std::string strHex = params[1].get_str();
std::vector<unsigned char> v = ParseHex(strHex);
std::string s(v.begin(), v.end());
UniValue u(UniValue::VOBJ);
u.read(s);
return u.write().c_str();
}
// PREPARE THE GOVERNANCE OBJECT BY CREATING A COLLATERAL TRANSACTION
if(strCommand == "prepare")
{
if (params.size() != 5) {
throw JSONRPCError(RPC_INVALID_PARAMETER, "Correct usage is 'gobject prepare <parent-hash> <revision> <time> <data-hex>'");
}
// ASSEMBLE NEW GOVERNANCE OBJECT FROM USER PARAMETERS
uint256 hashParent;
// -- attach to root node (root node doesn't really exist, but has a hash of zero)
if(params[1].get_str() == "0") {
hashParent = uint256();
} else {
hashParent = ParseHashV(params[1], "fee-txid, parameter 1");
}
std::string strRevision = params[2].get_str();
std::string strTime = params[3].get_str();
int nRevision = boost::lexical_cast<int>(strRevision);
int nTime = boost::lexical_cast<int>(strTime);
std::string strData = params[4].get_str();
// CREATE A NEW COLLATERAL TRANSACTION FOR THIS SPECIFIC OBJECT
CGovernanceObject govobj(hashParent, nRevision, nTime, uint256(), strData);
if((govobj.GetObjectType() == GOVERNANCE_OBJECT_TRIGGER) ||
(govobj.GetObjectType() == GOVERNANCE_OBJECT_WATCHDOG)) {
throw JSONRPCError(RPC_INVALID_PARAMETER, "Trigger and watchdog objects need not be prepared (however only masternodes can create them)");
}
std::string strError = "";
if(!govobj.IsValidLocally(strError, false))
throw JSONRPCError(RPC_INTERNAL_ERROR, "Governance object is not valid - " + govobj.GetHash().ToString() + " - " + strError);
CWalletTx wtx;
if(!pwalletMain->GetBudgetSystemCollateralTX(wtx, govobj.GetHash(), govobj.GetMinCollateralFee(), false)) {
throw JSONRPCError(RPC_INTERNAL_ERROR, "Error making collateral transaction for governance object. Please check your wallet balance and make sure your wallet is unlocked.");
}
// -- make our change address
CReserveKey reservekey(pwalletMain);
// -- send the tx to the network
pwalletMain->CommitTransaction(wtx, reservekey, NetMsgType::TX);
DBG( cout << "gobject: prepare "
<< " strData = " << govobj.GetDataAsString()
<< ", hash = " << govobj.GetHash().GetHex()
<< ", txidFee = " << wtx.GetHash().GetHex()
<< endl; );
return wtx.GetHash().ToString();
}
// AFTER COLLATERAL TRANSACTION HAS MATURED USER CAN SUBMIT GOVERNANCE OBJECT TO PROPAGATE NETWORK
if(strCommand == "submit")
{
if ((params.size() < 5) || (params.size() > 6)) {
throw JSONRPCError(RPC_INVALID_PARAMETER, "Correct usage is 'gobject submit <parent-hash> <revision> <time> <data-hex> <fee-txid>'");
}
if(!masternodeSync.IsBlockchainSynced()) {
throw JSONRPCError(RPC_CLIENT_IN_INITIAL_DOWNLOAD, "Must wait for client to sync with masternode network. Try again in a minute or so.");
}
CMasternode mn;
bool fMnFound = mnodeman.Get(activeMasternode.vin, mn);
DBG( cout << "gobject: submit activeMasternode.pubKeyMasternode = " << activeMasternode.pubKeyMasternode.GetHash().ToString()
<< ", vin = " << activeMasternode.vin.prevout.ToStringShort()
<< ", params.size() = " << params.size()
<< ", fMnFound = " << fMnFound << endl; );
// ASSEMBLE NEW GOVERNANCE OBJECT FROM USER PARAMETERS
uint256 txidFee;
if(params.size() == 6) {
txidFee = ParseHashV(params[5], "fee-txid, parameter 6");
}
uint256 hashParent;
if(params[1].get_str() == "0") { // attach to root node (root node doesn't really exist, but has a hash of zero)
hashParent = uint256();
} else {
hashParent = ParseHashV(params[1], "parent object hash, parameter 2");
}
// GET THE PARAMETERS FROM USER
std::string strRevision = params[2].get_str();
std::string strTime = params[3].get_str();
int nRevision = boost::lexical_cast<int>(strRevision);
int nTime = boost::lexical_cast<int>(strTime);
std::string strData = params[4].get_str();
CGovernanceObject govobj(hashParent, nRevision, nTime, txidFee, strData);
DBG( cout << "gobject: submit "
<< " strData = " << govobj.GetDataAsString()
<< ", hash = " << govobj.GetHash().GetHex()
<< ", txidFee = " << txidFee.GetHex()
<< endl; );
// Attempt to sign triggers if we are a MN
if((govobj.GetObjectType() == GOVERNANCE_OBJECT_TRIGGER) ||
(govobj.GetObjectType() == GOVERNANCE_OBJECT_WATCHDOG)) {
if(fMnFound) {
govobj.SetMasternodeInfo(mn.vin);
govobj.Sign(activeMasternode.keyMasternode, activeMasternode.pubKeyMasternode);
}
else {
LogPrintf("gobject(submit) -- Object submission rejected because node is not a masternode\n");
throw JSONRPCError(RPC_INVALID_PARAMETER, "Only valid masternodes can submit this type of object");
}
}
else {
if(params.size() != 6) {
LogPrintf("gobject(submit) -- Object submission rejected because fee tx not provided\n");
throw JSONRPCError(RPC_INVALID_PARAMETER, "The fee-txid parameter must be included to submit this type of object");
}
}
std::string strHash = govobj.GetHash().ToString();
std::string strError = "";
if(!govobj.IsValidLocally(strError, true)) {
LogPrintf("gobject(submit) -- Object submission rejected because object is not valid - hash = %s, strError = %s\n", strHash, strError);
throw JSONRPCError(RPC_INTERNAL_ERROR, "Governance object is not valid - " + strHash + " - " + strError);
}
// RELAY THIS OBJECT
// Reject if rate check fails but don't update buffer
if(!governance.MasternodeRateCheck(govobj)) {
LogPrintf("gobject(submit) -- Object submission rejected because of rate check failure - hash = %s\n", strHash);
throw JSONRPCError(RPC_INVALID_PARAMETER, "Object creation rate limit exceeded");
}
// This check should always pass, update buffer
if(!governance.MasternodeRateCheck(govobj, UPDATE_TRUE)) {
LogPrintf("gobject(submit) -- Object submission rejected because of rate check failure (buffer updated) - hash = %s\n", strHash);
throw JSONRPCError(RPC_INVALID_PARAMETER, "Object creation rate limit exceeded");
}
governance.AddSeenGovernanceObject(govobj.GetHash(), SEEN_OBJECT_IS_VALID);
govobj.Relay();
LogPrintf("gobject(submit) -- Adding locally created governance object - %s\n", strHash);
bool fAddToSeen = true;
governance.AddGovernanceObject(govobj, fAddToSeen);
return govobj.GetHash().ToString();
}
if(strCommand == "vote-conf")
{
if(params.size() != 4)
throw JSONRPCError(RPC_INVALID_PARAMETER, "Correct usage is 'gobject vote-conf <governance-hash> [funding|valid|delete] [yes|no|abstain]'");
uint256 hash;
std::string strVote;
hash = ParseHashV(params[1], "Object hash");
std::string strVoteSignal = params[2].get_str();
std::string strVoteOutcome = params[3].get_str();
vote_signal_enum_t eVoteSignal = CGovernanceVoting::ConvertVoteSignal(strVoteSignal);
if(eVoteSignal == VOTE_SIGNAL_NONE) {
throw JSONRPCError(RPC_INVALID_PARAMETER,
"Invalid vote signal. Please using one of the following: "
"(funding|valid|delete|endorsed) OR `custom sentinel code` ");
}
vote_outcome_enum_t eVoteOutcome = CGovernanceVoting::ConvertVoteOutcome(strVoteOutcome);
if(eVoteOutcome == VOTE_OUTCOME_NONE) {
throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid vote outcome. Please use one of the following: 'yes', 'no' or 'abstain'");
}
int nSuccessful = 0;
int nFailed = 0;
UniValue resultsObj(UniValue::VOBJ);
std::vector<unsigned char> vchMasterNodeSignature;
std::string strMasterNodeSignMessage;
UniValue statusObj(UniValue::VOBJ);
UniValue returnObj(UniValue::VOBJ);
CMasternode mn;
bool fMnFound = mnodeman.Get(activeMasternode.vin, mn);
if(!fMnFound) {
nFailed++;
statusObj.push_back(Pair("result", "failed"));
statusObj.push_back(Pair("errorMessage", "Can't find masternode by collateral output"));
resultsObj.push_back(Pair("bitcoinnode.conf", statusObj));
returnObj.push_back(Pair("overall", strprintf("Voted successfully %d time(s) and failed %d time(s).", nSuccessful, nFailed)));
returnObj.push_back(Pair("detail", resultsObj));
return returnObj;
}
CGovernanceVote vote(mn.vin, hash, eVoteSignal, eVoteOutcome);
if(!vote.Sign(activeMasternode.keyMasternode, activeMasternode.pubKeyMasternode)) {
nFailed++;
statusObj.push_back(Pair("result", "failed"));
statusObj.push_back(Pair("errorMessage", "Failure to sign."));
resultsObj.push_back(Pair("bitcoinnode.conf", statusObj));
returnObj.push_back(Pair("overall", strprintf("Voted successfully %d time(s) and failed %d time(s).", nSuccessful, nFailed)));
returnObj.push_back(Pair("detail", resultsObj));
return returnObj;
}
CGovernanceException exception;
if(governance.ProcessVoteAndRelay(vote, exception)) {
nSuccessful++;
statusObj.push_back(Pair("result", "success"));
}
else {
nFailed++;
statusObj.push_back(Pair("result", "failed"));
statusObj.push_back(Pair("errorMessage", exception.GetMessage()));
}
resultsObj.push_back(Pair("bitcoinnode.conf", statusObj));
returnObj.push_back(Pair("overall", strprintf("Voted successfully %d time(s) and failed %d time(s).", nSuccessful, nFailed)));
returnObj.push_back(Pair("detail", resultsObj));
return returnObj;
}
if(strCommand == "vote-many")
{
if(params.size() != 4)
throw JSONRPCError(RPC_INVALID_PARAMETER, "Correct usage is 'gobject vote-many <governance-hash> [funding|valid|delete] [yes|no|abstain]'");
uint256 hash;
std::string strVote;
hash = ParseHashV(params[1], "Object hash");
std::string strVoteSignal = params[2].get_str();
std::string strVoteOutcome = params[3].get_str();
vote_signal_enum_t eVoteSignal = CGovernanceVoting::ConvertVoteSignal(strVoteSignal);
if(eVoteSignal == VOTE_SIGNAL_NONE) {
throw JSONRPCError(RPC_INVALID_PARAMETER,
"Invalid vote signal. Please using one of the following: "
"(funding|valid|delete|endorsed) OR `custom sentinel code` ");
}
vote_outcome_enum_t eVoteOutcome = CGovernanceVoting::ConvertVoteOutcome(strVoteOutcome);
if(eVoteOutcome == VOTE_OUTCOME_NONE) {
throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid vote outcome. Please use one of the following: 'yes', 'no' or 'abstain'");
}
int nSuccessful = 0;
int nFailed = 0;
std::vector<CMasternodeConfig::CMasternodeEntry> mnEntries;
mnEntries = masternodeConfig.getEntries();
UniValue resultsObj(UniValue::VOBJ);
BOOST_FOREACH(CMasternodeConfig::CMasternodeEntry mne, masternodeConfig.getEntries()) {
std::string strError;
std::vector<unsigned char> vchMasterNodeSignature;
std::string strMasterNodeSignMessage;
CPubKey pubKeyCollateralAddress;
CKey keyCollateralAddress;
CPubKey pubKeyMasternode;
CKey keyMasternode;
UniValue statusObj(UniValue::VOBJ);
if(!darkSendSigner.GetKeysFromSecret(mne.getPrivKey(), keyMasternode, pubKeyMasternode)){
nFailed++;
statusObj.push_back(Pair("result", "failed"));
statusObj.push_back(Pair("errorMessage", "Masternode signing error, could not set key correctly"));
resultsObj.push_back(Pair(mne.getAlias(), statusObj));
continue;
}
uint256 nTxHash;
nTxHash.SetHex(mne.getTxHash());
int nOutputIndex = 0;
if(!ParseInt32(mne.getOutputIndex(), &nOutputIndex)) {
continue;
}
CTxIn vin(COutPoint(nTxHash, nOutputIndex));
CMasternode mn;
bool fMnFound = mnodeman.Get(vin, mn);
if(!fMnFound) {
nFailed++;
statusObj.push_back(Pair("result", "failed"));
statusObj.push_back(Pair("errorMessage", "Can't find masternode by collateral output"));
resultsObj.push_back(Pair(mne.getAlias(), statusObj));
continue;
}
CGovernanceVote vote(mn.vin, hash, eVoteSignal, eVoteOutcome);
if(!vote.Sign(keyMasternode, pubKeyMasternode)){
nFailed++;
statusObj.push_back(Pair("result", "failed"));
statusObj.push_back(Pair("errorMessage", "Failure to sign."));
resultsObj.push_back(Pair(mne.getAlias(), statusObj));
continue;
}
CGovernanceException exception;
if(governance.ProcessVoteAndRelay(vote, exception)) {
nSuccessful++;
statusObj.push_back(Pair("result", "success"));
}
else {
nFailed++;
statusObj.push_back(Pair("result", "failed"));
statusObj.push_back(Pair("errorMessage", exception.GetMessage()));
}
resultsObj.push_back(Pair(mne.getAlias(), statusObj));
}
UniValue returnObj(UniValue::VOBJ);
returnObj.push_back(Pair("overall", strprintf("Voted successfully %d time(s) and failed %d time(s).", nSuccessful, nFailed)));
returnObj.push_back(Pair("detail", resultsObj));
return returnObj;
}
// MASTERNODES CAN VOTE ON GOVERNANCE OBJECTS ON THE NETWORK FOR VARIOUS SIGNALS AND OUTCOMES
if(strCommand == "vote-alias")
{
if(params.size() != 5)
throw JSONRPCError(RPC_INVALID_PARAMETER, "Correct usage is 'gobject vote-alias <governance-hash> [funding|valid|delete] [yes|no|abstain] <alias-name>'");
uint256 hash;
std::string strVote;
// COLLECT NEEDED PARAMETRS FROM USER
hash = ParseHashV(params[1], "Object hash");
std::string strVoteSignal = params[2].get_str();
std::string strVoteOutcome = params[3].get_str();
std::string strAlias = params[4].get_str();
// CONVERT NAMED SIGNAL/ACTION AND CONVERT
vote_signal_enum_t eVoteSignal = CGovernanceVoting::ConvertVoteSignal(strVoteSignal);
if(eVoteSignal == VOTE_SIGNAL_NONE) {
throw JSONRPCError(RPC_INVALID_PARAMETER,
"Invalid vote signal. Please using one of the following: "
"(funding|valid|delete|endorsed) OR `custom sentinel code` ");
}
vote_outcome_enum_t eVoteOutcome = CGovernanceVoting::ConvertVoteOutcome(strVoteOutcome);
if(eVoteOutcome == VOTE_OUTCOME_NONE) {
throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid vote outcome. Please use one of the following: 'yes', 'no' or 'abstain'");
}
// EXECUTE VOTE FOR EACH MASTERNODE, COUNT SUCCESSES VS FAILURES
int nSuccessful = 0;
int nFailed = 0;
std::vector<CMasternodeConfig::CMasternodeEntry> mnEntries;
mnEntries = masternodeConfig.getEntries();
UniValue resultsObj(UniValue::VOBJ);
BOOST_FOREACH(CMasternodeConfig::CMasternodeEntry mne, masternodeConfig.getEntries())
{
// IF WE HAVE A SPECIFIC NODE REQUESTED TO VOTE, DO THAT
if(strAlias != mne.getAlias()) continue;
// INIT OUR NEEDED VARIABLES TO EXECUTE THE VOTE
std::string strError;
std::vector<unsigned char> vchMasterNodeSignature;
std::string strMasterNodeSignMessage;
CPubKey pubKeyCollateralAddress;
CKey keyCollateralAddress;
CPubKey pubKeyMasternode;
CKey keyMasternode;
// SETUP THE SIGNING KEY FROM MASTERNODE.CONF ENTRY
UniValue statusObj(UniValue::VOBJ);
if(!darkSendSigner.GetKeysFromSecret(mne.getPrivKey(), keyMasternode, pubKeyMasternode)) {
nFailed++;
statusObj.push_back(Pair("result", "failed"));
statusObj.push_back(Pair("errorMessage", strprintf("Invalid masternode key %s.", mne.getPrivKey())));
resultsObj.push_back(Pair(mne.getAlias(), statusObj));
continue;
}
// SEARCH FOR THIS MASTERNODE ON THE NETWORK, THE NODE MUST BE ACTIVE TO VOTE
uint256 nTxHash;
nTxHash.SetHex(mne.getTxHash());
int nOutputIndex = 0;
if(!ParseInt32(mne.getOutputIndex(), &nOutputIndex)) {
continue;
}
CTxIn vin(COutPoint(nTxHash, nOutputIndex));
CMasternode mn;
bool fMnFound = mnodeman.Get(vin, mn);
if(!fMnFound) {
nFailed++;
statusObj.push_back(Pair("result", "failed"));
statusObj.push_back(Pair("errorMessage", "Masternode must be publically available on network to vote. Masternode not found."));
resultsObj.push_back(Pair(mne.getAlias(), statusObj));
continue;
}
// CREATE NEW GOVERNANCE OBJECT VOTE WITH OUTCOME/SIGNAL
CGovernanceVote vote(vin, hash, eVoteSignal, eVoteOutcome);
if(!vote.Sign(keyMasternode, pubKeyMasternode)) {
nFailed++;
statusObj.push_back(Pair("result", "failed"));
statusObj.push_back(Pair("errorMessage", "Failure to sign."));
resultsObj.push_back(Pair(mne.getAlias(), statusObj));
continue;
}
// UPDATE LOCAL DATABASE WITH NEW OBJECT SETTINGS
CGovernanceException exception;
if(governance.ProcessVoteAndRelay(vote, exception)) {
nSuccessful++;
statusObj.push_back(Pair("result", "success"));
}
else {
nFailed++;
statusObj.push_back(Pair("result", "failed"));
statusObj.push_back(Pair("errorMessage", exception.GetMessage()));
}
resultsObj.push_back(Pair(mne.getAlias(), statusObj));
}
// REPORT STATS TO THE USER
UniValue returnObj(UniValue::VOBJ);
returnObj.push_back(Pair("overall", strprintf("Voted successfully %d time(s) and failed %d time(s).", nSuccessful, nFailed)));
returnObj.push_back(Pair("detail", resultsObj));
return returnObj;
}
// USERS CAN QUERY THE SYSTEM FOR A LIST OF VARIOUS GOVERNANCE ITEMS
if(strCommand == "list" || strCommand == "diff")
{
if (params.size() > 3)
throw JSONRPCError(RPC_INVALID_PARAMETER, "Correct usage is 'gobject [list|diff] [valid] [type]'");
// GET MAIN PARAMETER FOR THIS MODE, VALID OR ALL?
std::string strShow = "valid";
if (params.size() >= 2) strShow = params[1].get_str();
if (strShow != "valid" && strShow != "all")
return "Invalid mode, should be 'valid' or 'all'";
std::string strType = "all";
if (params.size() == 3) strType = params[2].get_str();
if (strType != "proposals" && strType != "triggers" && strType != "watchdogs" && strType != "all")
return "Invalid type, should be 'proposals', 'triggers', 'watchdogs' or 'all'";
// GET STARTING TIME TO QUERY SYSTEM WITH
int nStartTime = 0; //list
if(strCommand == "diff") nStartTime = governance.GetLastDiffTime();
// SETUP BLOCK INDEX VARIABLE / RESULTS VARIABLE
UniValue objResult(UniValue::VOBJ);
// GET MATCHING GOVERNANCE OBJECTS
LOCK2(cs_main, governance.cs);
std::vector<CGovernanceObject*> objs = governance.GetAllNewerThan(nStartTime);
governance.UpdateLastDiffTime(GetTime());
// CREATE RESULTS FOR USER
BOOST_FOREACH(CGovernanceObject* pGovObj, objs)
{
if(strShow == "valid" && !pGovObj->IsSetCachedValid()) continue;
if(strType == "proposals" && pGovObj->GetObjectType() != GOVERNANCE_OBJECT_PROPOSAL) continue;
if(strType == "triggers" && pGovObj->GetObjectType() != GOVERNANCE_OBJECT_TRIGGER) continue;
if(strType == "watchdogs" && pGovObj->GetObjectType() != GOVERNANCE_OBJECT_WATCHDOG) continue;
UniValue bObj(UniValue::VOBJ);
bObj.push_back(Pair("DataHex", pGovObj->GetDataAsHex()));
bObj.push_back(Pair("DataString", pGovObj->GetDataAsString()));
bObj.push_back(Pair("Hash", pGovObj->GetHash().ToString()));
bObj.push_back(Pair("CollateralHash", pGovObj->GetCollateralHash().ToString()));
bObj.push_back(Pair("ObjectType", pGovObj->GetObjectType()));
bObj.push_back(Pair("CreationTime", pGovObj->GetCreationTime()));
const CTxIn& masternodeVin = pGovObj->GetMasternodeVin();
if(masternodeVin != CTxIn()) {
bObj.push_back(Pair("SigningMasternode", masternodeVin.prevout.ToStringShort()));
}
// REPORT STATUS FOR FUNDING VOTES SPECIFICALLY
bObj.push_back(Pair("AbsoluteYesCount", pGovObj->GetAbsoluteYesCount(VOTE_SIGNAL_FUNDING)));
bObj.push_back(Pair("YesCount", pGovObj->GetYesCount(VOTE_SIGNAL_FUNDING)));
bObj.push_back(Pair("NoCount", pGovObj->GetNoCount(VOTE_SIGNAL_FUNDING)));
bObj.push_back(Pair("AbstainCount", pGovObj->GetAbstainCount(VOTE_SIGNAL_FUNDING)));
// REPORT VALIDITY AND CACHING FLAGS FOR VARIOUS SETTINGS
std::string strError = "";
bObj.push_back(Pair("fBlockchainValidity", pGovObj->IsValidLocally(strError, false)));
bObj.push_back(Pair("IsValidReason", strError.c_str()));
bObj.push_back(Pair("fCachedValid", pGovObj->IsSetCachedValid()));
bObj.push_back(Pair("fCachedFunding", pGovObj->IsSetCachedFunding()));
bObj.push_back(Pair("fCachedDelete", pGovObj->IsSetCachedDelete()));
bObj.push_back(Pair("fCachedEndorsed", pGovObj->IsSetCachedEndorsed()));
objResult.push_back(Pair(pGovObj->GetHash().ToString(), bObj));
}
return objResult;
}
// GET SPECIFIC GOVERNANCE ENTRY
if(strCommand == "get")
{
if (params.size() != 2)
throw JSONRPCError(RPC_INVALID_PARAMETER, "Correct usage is 'gobject get <governance-hash>'");
// COLLECT VARIABLES FROM OUR USER
uint256 hash = ParseHashV(params[1], "GovObj hash");
LOCK2(cs_main, governance.cs);
// FIND THE GOVERNANCE OBJECT THE USER IS LOOKING FOR
CGovernanceObject* pGovObj = governance.FindGovernanceObject(hash);
if(pGovObj == NULL)
throw JSONRPCError(RPC_INVALID_PARAMETER, "Unknown governance object");
// REPORT BASIC OBJECT STATS
UniValue objResult(UniValue::VOBJ);
objResult.push_back(Pair("DataHex", pGovObj->GetDataAsHex()));
objResult.push_back(Pair("DataString", pGovObj->GetDataAsString()));
objResult.push_back(Pair("Hash", pGovObj->GetHash().ToString()));
objResult.push_back(Pair("CollateralHash", pGovObj->GetCollateralHash().ToString()));
objResult.push_back(Pair("ObjectType", pGovObj->GetObjectType()));
objResult.push_back(Pair("CreationTime", pGovObj->GetCreationTime()));
const CTxIn& masternodeVin = pGovObj->GetMasternodeVin();
if(masternodeVin != CTxIn()) {
objResult.push_back(Pair("SigningMasternode", masternodeVin.prevout.ToStringShort()));
}
// SHOW (MUCH MORE) INFORMATION ABOUT VOTES FOR GOVERNANCE OBJECT (THAN LIST/DIFF ABOVE)
// -- FUNDING VOTING RESULTS
UniValue objFundingResult(UniValue::VOBJ);
objFundingResult.push_back(Pair("AbsoluteYesCount", pGovObj->GetAbsoluteYesCount(VOTE_SIGNAL_FUNDING)));
objFundingResult.push_back(Pair("YesCount", pGovObj->GetYesCount(VOTE_SIGNAL_FUNDING)));
objFundingResult.push_back(Pair("NoCount", pGovObj->GetNoCount(VOTE_SIGNAL_FUNDING)));
objFundingResult.push_back(Pair("AbstainCount", pGovObj->GetAbstainCount(VOTE_SIGNAL_FUNDING)));
objResult.push_back(Pair("FundingResult", objFundingResult));
// -- VALIDITY VOTING RESULTS
UniValue objValid(UniValue::VOBJ);
objValid.push_back(Pair("AbsoluteYesCount", pGovObj->GetAbsoluteYesCount(VOTE_SIGNAL_VALID)));
objValid.push_back(Pair("YesCount", pGovObj->GetYesCount(VOTE_SIGNAL_VALID)));
objValid.push_back(Pair("NoCount", pGovObj->GetNoCount(VOTE_SIGNAL_VALID)));
objValid.push_back(Pair("AbstainCount", pGovObj->GetAbstainCount(VOTE_SIGNAL_VALID)));
objResult.push_back(Pair("ValidResult", objValid));
// -- DELETION CRITERION VOTING RESULTS
UniValue objDelete(UniValue::VOBJ);
objDelete.push_back(Pair("AbsoluteYesCount", pGovObj->GetAbsoluteYesCount(VOTE_SIGNAL_DELETE)));
objDelete.push_back(Pair("YesCount", pGovObj->GetYesCount(VOTE_SIGNAL_DELETE)));
objDelete.push_back(Pair("NoCount", pGovObj->GetNoCount(VOTE_SIGNAL_DELETE)));
objDelete.push_back(Pair("AbstainCount", pGovObj->GetAbstainCount(VOTE_SIGNAL_DELETE)));
objResult.push_back(Pair("DeleteResult", objDelete));
// -- ENDORSED VIA MASTERNODE-ELECTED BOARD
UniValue objEndorsed(UniValue::VOBJ);
objEndorsed.push_back(Pair("AbsoluteYesCount", pGovObj->GetAbsoluteYesCount(VOTE_SIGNAL_ENDORSED)));
objEndorsed.push_back(Pair("YesCount", pGovObj->GetYesCount(VOTE_SIGNAL_ENDORSED)));
objEndorsed.push_back(Pair("NoCount", pGovObj->GetNoCount(VOTE_SIGNAL_ENDORSED)));
objEndorsed.push_back(Pair("AbstainCount", pGovObj->GetAbstainCount(VOTE_SIGNAL_ENDORSED)));
objResult.push_back(Pair("EndorsedResult", objEndorsed));
// --
std::string strError = "";
objResult.push_back(Pair("fLocalValidity", pGovObj->IsValidLocally(strError, false)));
objResult.push_back(Pair("IsValidReason", strError.c_str()));
objResult.push_back(Pair("fCachedValid", pGovObj->IsSetCachedValid()));
objResult.push_back(Pair("fCachedFunding", pGovObj->IsSetCachedFunding()));
objResult.push_back(Pair("fCachedDelete", pGovObj->IsSetCachedDelete()));
objResult.push_back(Pair("fCachedEndorsed", pGovObj->IsSetCachedEndorsed()));
return objResult;
}
// GETVOTES FOR SPECIFIC GOVERNANCE OBJECT
if(strCommand == "getvotes")
{
if (params.size() != 2)
throw std::runtime_error(
"Correct usage is 'gobject getvotes <governance-hash>'"
);
// COLLECT PARAMETERS FROM USER
uint256 hash = ParseHashV(params[1], "Governance hash");
// FIND OBJECT USER IS LOOKING FOR
LOCK(governance.cs);
CGovernanceObject* pGovObj = governance.FindGovernanceObject(hash);
if(pGovObj == NULL) {
throw JSONRPCError(RPC_INVALID_PARAMETER, "Unknown governance-hash");
}
// REPORT RESULTS TO USER
UniValue bResult(UniValue::VOBJ);
// GET MATCHING VOTES BY HASH, THEN SHOW USERS VOTE INFORMATION
std::vector<CGovernanceVote> vecVotes = governance.GetMatchingVotes(hash);
BOOST_FOREACH(CGovernanceVote vote, vecVotes) {
bResult.push_back(Pair(vote.GetHash().ToString(), vote.ToString()));
}
return bResult;
}
// GETVOTES FOR SPECIFIC GOVERNANCE OBJECT
if(strCommand == "getcurrentvotes")
{
if (params.size() != 2 && params.size() != 4)
throw std::runtime_error(
"Correct usage is 'gobject getcurrentvotes <governance-hash> [txid vout_index]'"
);
// COLLECT PARAMETERS FROM USER
uint256 hash = ParseHashV(params[1], "Governance hash");
CTxIn mnCollateralOutpoint;
if (params.size() == 4) {
uint256 txid = ParseHashV(params[2], "Masternode Collateral hash");
std::string strVout = params[3].get_str();
uint32_t vout = boost::lexical_cast<uint32_t>(strVout);
mnCollateralOutpoint = CTxIn(txid, vout);
}
// FIND OBJECT USER IS LOOKING FOR
LOCK(governance.cs);
CGovernanceObject* pGovObj = governance.FindGovernanceObject(hash);
if(pGovObj == NULL) {
throw JSONRPCError(RPC_INVALID_PARAMETER, "Unknown governance-hash");
}
// REPORT RESULTS TO USER
UniValue bResult(UniValue::VOBJ);
// GET MATCHING VOTES BY HASH, THEN SHOW USERS VOTE INFORMATION
std::vector<CGovernanceVote> vecVotes = governance.GetCurrentVotes(hash, mnCollateralOutpoint);
BOOST_FOREACH(CGovernanceVote vote, vecVotes) {
bResult.push_back(Pair(vote.GetHash().ToString(), vote.ToString()));
}
return bResult;
}
return NullUniValue;
}
UniValue voteraw(const UniValue& params, bool fHelp)
{
if (fHelp || params.size() != 7)
throw std::runtime_error(
"voteraw <masternode-tx-hash> <masternode-tx-index> <governance-hash> <vote-signal> [yes|no|abstain] <time> <vote-sig>\n"
"Compile and relay a governance vote with provided external signature instead of signing vote internally\n"
);
uint256 hashMnTx = ParseHashV(params[0], "mn tx hash");
int nMnTxIndex = params[1].get_int();
CTxIn vin = CTxIn(hashMnTx, nMnTxIndex);
uint256 hashGovObj = ParseHashV(params[2], "Governance hash");
std::string strVoteSignal = params[3].get_str();
std::string strVoteOutcome = params[4].get_str();
vote_signal_enum_t eVoteSignal = CGovernanceVoting::ConvertVoteSignal(strVoteSignal);
if(eVoteSignal == VOTE_SIGNAL_NONE) {
throw JSONRPCError(RPC_INVALID_PARAMETER,
"Invalid vote signal. Please using one of the following: "
"(funding|valid|delete|endorsed) OR `custom sentinel code` ");
}
vote_outcome_enum_t eVoteOutcome = CGovernanceVoting::ConvertVoteOutcome(strVoteOutcome);
if(eVoteOutcome == VOTE_OUTCOME_NONE) {
throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid vote outcome. Please use one of the following: 'yes', 'no' or 'abstain'");
}
int64_t nTime = params[5].get_int64();
std::string strSig = params[6].get_str();
bool fInvalid = false;
std::vector<unsigned char> vchSig = DecodeBase64(strSig.c_str(), &fInvalid);
if (fInvalid) {
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Malformed base64 encoding");
}
CMasternode mn;
bool fMnFound = mnodeman.Get(vin, mn);
if(!fMnFound) {
throw JSONRPCError(RPC_INTERNAL_ERROR, "Failure to find masternode in list : " + vin.prevout.ToStringShort());
}
CGovernanceVote vote(vin, hashGovObj, eVoteSignal, eVoteOutcome);
vote.SetTime(nTime);
vote.SetSignature(vchSig);
if(!vote.IsValid(true)) {
throw JSONRPCError(RPC_INTERNAL_ERROR, "Failure to verify vote.");
}
CGovernanceException exception;
if(governance.ProcessVoteAndRelay(vote, exception)) {
return "Voted successfully";
}
else {
throw JSONRPCError(RPC_INTERNAL_ERROR, "Error voting : " + exception.GetMessage());
}
}
UniValue getgovernanceinfo(const UniValue& params, bool fHelp)
{
if (fHelp || params.size() != 0) {
throw std::runtime_error(
"getgovernanceinfo\n"
"Returns an object containing governance parameters.\n"
"\nResult:\n"
"{\n"
" \"governanceminquorum\": xxxxx, (numeric) the absolute minimum number of votes needed to trigger a governance action\n"
" \"masternodewatchdogmaxseconds\": xxxxx, (numeric) sentinel watchdog expiration time in seconds\n"
" \"proposalfee\": xxx.xx, (numeric) the collateral transaction fee which must be paid to create a proposal in " + CURRENCY_UNIT + "\n"
" \"superblockcycle\": xxxxx, (numeric) the number of blocks between superblocks\n"
" \"lastsuperblock\": xxxxx, (numeric) the block number of the last superblock\n"
" \"nextsuperblock\": xxxxx, (numeric) the block number of the next superblock\n"
"}\n"
"\nExamples:\n"
+ HelpExampleCli("getgovernanceinfo", "")
+ HelpExampleRpc("getgovernanceinfo", "")
);
}
// Compute last/next superblock
int nLastSuperblock, nNextSuperblock;
// Get current block height
int nBlockHeight = 0;
{
LOCK(cs_main);
nBlockHeight = (int)chainActive.Height();
}
// Get chain parameters
int nSuperblockStartBlock = Params().GetConsensus().nSuperblockStartBlock;
int nSuperblockCycle = Params().GetConsensus().nSuperblockCycle;
// Get first superblock
int nFirstSuperblockOffset = (nSuperblockCycle - nSuperblockStartBlock % nSuperblockCycle) % nSuperblockCycle;
int nFirstSuperblock = nSuperblockStartBlock + nFirstSuperblockOffset;
if(nBlockHeight < nFirstSuperblock){
nLastSuperblock = 0;
nNextSuperblock = nFirstSuperblock;
} else {
nLastSuperblock = nBlockHeight - nBlockHeight % nSuperblockCycle;
nNextSuperblock = nLastSuperblock + nSuperblockCycle;
}
UniValue obj(UniValue::VOBJ);
obj.push_back(Pair("governanceminquorum", Params().GetConsensus().nGovernanceMinQuorum));
obj.push_back(Pair("masternodewatchdogmaxseconds", MASTERNODE_WATCHDOG_MAX_SECONDS));
obj.push_back(Pair("proposalfee", ValueFromAmount(GOVERNANCE_PROPOSAL_FEE_TX)));
obj.push_back(Pair("superblockcycle", Params().GetConsensus().nSuperblockCycle));
obj.push_back(Pair("lastsuperblock", nLastSuperblock));
obj.push_back(Pair("nextsuperblock", nNextSuperblock));
return obj;
}
UniValue getsuperblockbudget(const UniValue& params, bool fHelp)
{
if (fHelp || params.size() != 1) {
throw std::runtime_error(
"getsuperblockbudget index\n"
"\nReturns the absolute maximum sum of superblock payments allowed.\n"
"\nArguments:\n"
"1. index (numeric, required) The block index\n"
"\nResult:\n"
"n (numeric) The absolute maximum sum of superblock payments allowed, in " + CURRENCY_UNIT + "\n"
"\nExamples:\n"
+ HelpExampleCli("getsuperblockbudget", "1000")
+ HelpExampleRpc("getsuperblockbudget", "1000")
);
}
int nBlockHeight = params[0].get_int();
if (nBlockHeight < 0) {
throw JSONRPCError(RPC_INVALID_PARAMETER, "Block height out of range");
}
CAmount nBudget = CSuperblock::GetPaymentsLimit(nBlockHeight);
std::string strBudget = FormatMoney(nBudget);
return strBudget;
}
|
/*
* Copyright (c) 2015-2016, Graphics Lab, Georgia Tech Research Corporation
* Copyright (c) 2015-2016, Humanoid Lab, Georgia Tech Research Corporation
* Copyright (c) 2016, Personal Robotics Lab, Carnegie Mellon University
* All rights reserved.
*
* This file is provided under the following "BSD-style" License:
* Redistribution and use in source and binary forms, with or
* without modification, are permitted provided that the following
* conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#include "dart/dart.hpp"
#include "dart/gui/gui.hpp"
const double default_height = 1.0; // m
const double default_width = 0.2; // m
const double default_depth = 0.2; // m
const double default_torque = 15.0; // N-m
const double default_force = 15.0; // N
const int default_countdown = 200; // Number of timesteps for applying force
const double default_rest_position = 0.0;
const double delta_rest_position = 10.0 * M_PI / 180.0;
const double default_stiffness = 0.0;
const double delta_stiffness = 10;
const double default_damping = 5.0;
const double delta_damping = 1.0;
using namespace dart::dynamics;
using namespace dart::simulation;
class MyWindow : public dart::gui::SimWindow
{
public:
/// Constructor
MyWindow(WorldPtr world)
: mBallConstraint(nullptr),
mPositiveSign(true),
mBodyForce(false)
{
setWorld(world);
// Find the Skeleton named "pendulum" within the World
mPendulum = world->getSkeleton("pendulum");
// Make sure that the pendulum was found in the World
assert(mPendulum != nullptr);
mForceCountDown.resize(mPendulum->getNumDofs(), 0);
ArrowShape::Properties arrow_properties;
arrow_properties.mRadius = 0.05;
mArrow = std::shared_ptr<ArrowShape>(new ArrowShape(
Eigen::Vector3d(-default_height, 0.0, default_height / 2.0),
Eigen::Vector3d(-default_width / 2.0, 0.0, default_height / 2.0),
arrow_properties, dart::Color::Orange(1.0)));
}
void changeDirection()
{
mPositiveSign = !mPositiveSign;
if(mPositiveSign)
{
mArrow->setPositions(
Eigen::Vector3d(-default_height, 0.0, default_height / 2.0),
Eigen::Vector3d(-default_width / 2.0, 0.0, default_height / 2.0));
}
else
{
mArrow->setPositions(
Eigen::Vector3d(default_height, 0.0, default_height / 2.0),
Eigen::Vector3d(default_width / 2.0, 0.0, default_height / 2.0));
}
}
void applyForce(std::size_t index)
{
if(index < mForceCountDown.size())
mForceCountDown[index] = default_countdown;
}
void changeRestPosition(double delta)
{
for(std::size_t i = 0; i < mPendulum->getNumDofs(); ++i)
{
DegreeOfFreedom* dof = mPendulum->getDof(i);
double q0 = dof->getRestPosition() + delta;
// The system becomes numerically unstable when the rest position exceeds
// 90 degrees
if(std::abs(q0) > 90.0 * M_PI / 180.0)
q0 = (q0 > 0)? (90.0 * M_PI / 180.0) : -(90.0 * M_PI / 180.0);
dof->setRestPosition(q0);
}
// Only curl up along one axis in the BallJoint
mPendulum->getDof(0)->setRestPosition(0.0);
mPendulum->getDof(2)->setRestPosition(0.0);
}
void changeStiffness(double delta)
{
for(std::size_t i = 0; i < mPendulum->getNumDofs(); ++i)
{
DegreeOfFreedom* dof = mPendulum->getDof(i);
double stiffness = dof->getSpringStiffness() + delta;
if(stiffness < 0.0)
stiffness = 0.0;
dof->setSpringStiffness(stiffness);
}
}
void changeDamping(double delta)
{
for(std::size_t i = 0; i < mPendulum->getNumDofs(); ++i)
{
DegreeOfFreedom* dof = mPendulum->getDof(i);
double damping = dof->getDampingCoefficient() + delta;
if(damping < 0.0)
damping = 0.0;
dof->setDampingCoefficient(damping);
}
}
/// Add a constraint to attach the final link to the world
void addConstraint()
{
// Get the last body in the pendulum
BodyNode* tip = mPendulum->getBodyNode(mPendulum->getNumBodyNodes() - 1);
// Attach the last link to the world
Eigen::Vector3d location =
tip->getTransform() * Eigen::Vector3d(0.0, 0.0, default_height);
mBallConstraint =
std::make_shared<dart::constraint::BallJointConstraint>(tip, location);
mWorld->getConstraintSolver()->addConstraint(mBallConstraint);
}
/// Remove any existing constraint, allowing the pendulum to flail freely
void removeConstraint()
{
mWorld->getConstraintSolver()->removeConstraint(mBallConstraint);
mBallConstraint = nullptr;
}
/// Handle keyboard input
void keyboard(unsigned char key, int x, int y) override
{
switch(key)
{
case '-':
changeDirection();
break;
case '1':
applyForce(0);
break;
case '2':
applyForce(1);
break;
case '3':
applyForce(2);
break;
case '4':
applyForce(3);
break;
case '5':
applyForce(4);
break;
case '6':
applyForce(5);
break;
case '7':
applyForce(6);
break;
case '8':
applyForce(7);
break;
case '9':
applyForce(8);
break;
case '0':
applyForce(9);
break;
case 'q':
changeRestPosition(delta_rest_position);
break;
case 'a':
changeRestPosition(-delta_rest_position);
break;
case 'w':
changeStiffness(delta_stiffness);
break;
case 's':
changeStiffness(-delta_stiffness);
break;
case 'e':
changeDamping(delta_damping);
break;
case 'd':
changeDamping(-delta_damping);
break;
case 'r':
{
if(mBallConstraint)
removeConstraint();
else
addConstraint();
break;
}
case 'f':
mBodyForce = !mBodyForce;
break;
default:
SimWindow::keyboard(key, x, y);
}
}
void timeStepping() override
{
// Reset all the shapes to be Blue
for(std::size_t i = 0; i < mPendulum->getNumBodyNodes(); ++i)
{
BodyNode* bn = mPendulum->getBodyNode(i);
auto visualShapeNodes = bn->getShapeNodesWith<VisualAspect>();
for(std::size_t j = 0; j < 2; ++j)
visualShapeNodes[j]->getVisualAspect()->setColor(dart::Color::Blue());
// If we have three visualization shapes, that means the arrow is
// attached. We should remove it in case this body is no longer
// experiencing a force
if(visualShapeNodes.size() == 3u)
{
assert(visualShapeNodes[2]->getShape() == mArrow);
visualShapeNodes[2]->remove();
}
}
if(!mBodyForce)
{
// Apply joint torques based on user input, and color the Joint shape red
for(std::size_t i = 0; i < mPendulum->getNumDofs(); ++i)
{
if(mForceCountDown[i] > 0)
{
DegreeOfFreedom* dof = mPendulum->getDof(i);
dof->setForce( mPositiveSign? default_torque : -default_torque );
BodyNode* bn = dof->getChildBodyNode();
auto visualShapeNodes = bn->getShapeNodesWith<VisualAspect>();
visualShapeNodes[0]->getVisualAspect()->setColor(dart::Color::Red());
--mForceCountDown[i];
}
}
}
else
{
// Apply body forces based on user input, and color the body shape red
for(std::size_t i = 0; i < mPendulum->getNumBodyNodes(); ++i)
{
if(mForceCountDown[i] > 0)
{
BodyNode* bn = mPendulum->getBodyNode(i);
Eigen::Vector3d force = default_force * Eigen::Vector3d::UnitX();
Eigen::Vector3d location(-default_width / 2.0, 0.0, default_height / 2.0);
if(!mPositiveSign)
{
force = -force;
location[0] = -location[0];
}
bn->addExtForce(force, location, true, true);
auto shapeNodes = bn->getShapeNodesWith<VisualAspect>();
shapeNodes[1]->getVisualAspect()->setColor(dart::Color::Red());
bn->createShapeNodeWith<VisualAspect>(mArrow);
--mForceCountDown[i];
}
}
}
// Step the simulation forward
SimWindow::timeStepping();
}
protected:
/// An arrow shape that we will use to visualize applied forces
std::shared_ptr<ArrowShape> mArrow;
/// The pendulum that we will be perturbing
SkeletonPtr mPendulum;
/// Pointer to the ball constraint that we will be turning on and off
dart::constraint::BallJointConstraintPtr mBallConstraint;
/// Number of iterations before clearing a force entry
std::vector<int> mForceCountDown;
/// Whether a force should be applied in the positive or negative direction
bool mPositiveSign;
/// True if 1-9 should be used to apply a body force. Otherwise, 1-9 will be
/// used to apply a joint torque.
bool mBodyForce;
};
void setGeometry(const BodyNodePtr& bn)
{
// Create a BoxShape to be used for both visualization and collision checking
std::shared_ptr<BoxShape> box(new BoxShape(
Eigen::Vector3d(default_width, default_depth, default_height)));
// Create a shape node for visualization and collision checking
auto shapeNode
= bn->createShapeNodeWith<VisualAspect, CollisionAspect, DynamicsAspect>(box);
shapeNode->getVisualAspect()->setColor(dart::Color::Blue());
// Set the location of the shape node
Eigen::Isometry3d box_tf(Eigen::Isometry3d::Identity());
Eigen::Vector3d center = Eigen::Vector3d(0, 0, default_height / 2.0);
box_tf.translation() = center;
shapeNode->setRelativeTransform(box_tf);
// Move the center of mass to the center of the object
bn->setLocalCOM(center);
}
BodyNode* makeRootBody(const SkeletonPtr& pendulum, const std::string& name)
{
BallJoint::Properties properties;
properties.mName = name + "_joint";
properties.mRestPositions = Eigen::Vector3d::Constant(default_rest_position);
properties.mSpringStiffnesses = Eigen::Vector3d::Constant(default_stiffness);
properties.mDampingCoefficients = Eigen::Vector3d::Constant(default_damping);
BodyNodePtr bn = pendulum->createJointAndBodyNodePair<BallJoint>(
nullptr, properties, BodyNode::AspectProperties(name)).second;
// Make a shape for the Joint
const double& R = default_width;
std::shared_ptr<EllipsoidShape> ball(
new EllipsoidShape(sqrt(2) * Eigen::Vector3d(R, R, R)));
auto shapeNode = bn->createShapeNodeWith<VisualAspect>(ball);
shapeNode->getVisualAspect()->setColor(dart::Color::Blue());
// Set the geometry of the Body
setGeometry(bn);
return bn;
}
BodyNode* addBody(const SkeletonPtr& pendulum, BodyNode* parent,
const std::string& name)
{
// Set up the properties for the Joint
RevoluteJoint::Properties properties;
properties.mName = name + "_joint";
properties.mAxis = Eigen::Vector3d::UnitY();
properties.mT_ParentBodyToJoint.translation() =
Eigen::Vector3d(0, 0, default_height);
properties.mRestPositions[0] = default_rest_position;
properties.mSpringStiffnesses[0] = default_stiffness;
properties.mDampingCoefficients[0] = default_damping;
// Create a new BodyNode, attached to its parent by a RevoluteJoint
BodyNodePtr bn = pendulum->createJointAndBodyNodePair<RevoluteJoint>(
parent, properties, BodyNode::AspectProperties(name)).second;
// Make a shape for the Joint
const double R = default_width / 2.0;
const double h = default_depth;
std::shared_ptr<CylinderShape> cyl(new CylinderShape(R, h));
// Line up the cylinder with the Joint axis
Eigen::Isometry3d tf(Eigen::Isometry3d::Identity());
tf.linear() = dart::math::eulerXYZToMatrix(
Eigen::Vector3d(90.0 * M_PI / 180.0, 0, 0));
auto shapeNode = bn->createShapeNodeWith<VisualAspect>(cyl);
shapeNode->getVisualAspect()->setColor(dart::Color::Blue());
shapeNode->setRelativeTransform(tf);
// Set the geometry of the Body
setGeometry(bn);
return bn;
}
int main(int argc, char* argv[])
{
// Create an empty Skeleton with the name "pendulum"
SkeletonPtr pendulum = Skeleton::create("pendulum");
// Add each body to the last BodyNode in the pendulum
BodyNode* bn = makeRootBody(pendulum, "body1");
bn = addBody(pendulum, bn, "body2");
bn = addBody(pendulum, bn, "body3");
bn = addBody(pendulum, bn, "body4");
bn = addBody(pendulum, bn, "body5");
// Set the initial position of the first DegreeOfFreedom so that the pendulum
// starts to swing right away
pendulum->getDof(1)->setPosition(120 * M_PI / 180.0);
// Create a world and add the pendulum to the world
WorldPtr world(new World);
world->addSkeleton(pendulum);
// Create a window for rendering the world and handling user input
MyWindow window(world);
// Print instructions
std::cout << "space bar: simulation on/off" << std::endl;
std::cout << "'p': replay simulation" << std::endl;
std::cout << "'1' -> '9': apply torque to a pendulum body" << std::endl;
std::cout << "'-': Change sign of applied joint torques" << std::endl;
std::cout << "'q': Increase joint rest positions" << std::endl;
std::cout << "'a': Decrease joint rest positions" << std::endl;
std::cout << "'w': Increase joint spring stiffness" << std::endl;
std::cout << "'s': Decrease joint spring stiffness" << std::endl;
std::cout << "'e': Increase joint damping" << std::endl;
std::cout << "'d': Decrease joint damping" << std::endl;
std::cout << "'r': add/remove constraint on the end of the chain" << std::endl;
std::cout << "'f': switch between applying joint torques and body forces" << std::endl;
// Initialize glut, initialize the window, and begin the glut event loop
glutInit(&argc, argv);
window.initWindow(640, 480, "Multi-Pendulum Tutorial");
glutMainLoop();
}
|
; A077880: Expansion of (1-x)^(-1)/(1-2*x^2+x^3).
; 1,1,3,2,6,2,11,-1,21,-12,44,-44,101,-131,247,-362,626,-970,1615,-2565,4201,-6744,10968,-17688,28681,-46343,75051,-121366,196446,-317782,514259,-832009,1346301,-2178276,3524612,-5702852,9227501,-14930315,24157855,-39088130,63246026,-102334114
mov $1,$0
cal $0,119282 ; Alternating sum of the first n Fibonacci numbers.
add $1,$0
add $1,1
|
; A059924: Write the numbers from 1 to n^2 in a spiraling square; a(n) is the total of the sums of the two diagonals.
; 0,2,10,34,80,158,274,438,656,938,1290,1722,2240,2854,3570,4398,5344,6418,7626,8978,10480,12142,13970,15974,18160,20538,23114,25898,28896,32118,35570,39262,43200,47394,51850,56578,61584,66878,72466,78358,84560,91082,97930,105114,112640,120518,128754,137358,146336,155698,165450,175602,186160,197134,208530,220358,232624,245338,258506,272138,286240,300822,315890,331454,347520,364098,381194,398818,416976,435678,454930,474742,495120,516074,537610,559738,582464,605798,629746,654318,679520,705362,731850,758994,786800,815278,844434,874278,904816,936058,968010,1000682,1034080,1068214,1103090,1138718,1175104,1212258,1250186,1288898,1328400,1368702,1409810,1451734,1494480,1538058,1582474,1627738,1673856,1720838,1768690,1817422,1867040,1917554,1968970,2021298,2074544,2128718,2183826,2239878,2296880,2354842,2413770,2473674,2534560,2596438,2659314,2723198,2788096,2854018,2920970,2988962,3058000,3128094,3199250,3271478,3344784,3419178,3494666,3571258,3648960,3727782,3807730,3888814,3971040,4054418,4138954,4224658,4311536,4399598,4488850,4579302,4670960,4763834,4857930,4953258,5049824,5147638,5246706,5347038,5448640,5551522,5655690,5761154,5867920,5975998,6085394,6196118,6308176,6421578,6536330,6652442,6769920,6888774,7009010,7130638,7253664,7378098,7503946,7631218,7759920,7890062,8021650,8154694,8289200,8425178,8562634,8701578,8842016,8983958,9127410,9272382,9418880,9566914,9716490,9867618,10020304,10174558,10330386,10487798,10646800,10807402,10969610,11133434,11298880,11465958,11634674,11805038,11977056,12150738,12326090,12503122,12681840,12862254,13044370,13228198,13413744,13601018,13790026,13980778,14173280,14367542,14563570,14761374,14960960,15162338,15365514,15570498,15777296,15985918,16196370,16408662,16622800,16838794,17056650,17276378,17497984,17721478,17946866,18174158,18403360,18634482,18867530,19102514,19339440,19578318,19819154,20061958,20306736,20553498
mov $5,$0
mul $0,2
mov $1,3
mov $2,$0
mov $4,3
lpb $2,1
lpb $4,1
sub $2,2
trn $4,$1
lpe
mov $0,$2
sub $2,1
mov $3,$0
add $3,$2
lpb $0,1
sub $0,1
add $1,$3
add $4,4
lpe
sub $2,1
lpe
lpb $5,1
add $1,2
sub $5,1
lpe
sub $1,3
|
#include <libng_engine/net/NetEngine.hpp>
namespace libng {
NetEngine::NetEngine() {
}
NetEngine::~NetEngine() {
}
} // namespace libng |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Parutil
; Multi-platform library of parallelized utility functions.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Authored by Samuel Grossman
; Department of Electrical Engineering, Stanford University
; Copyright (c) 2016-2017
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; atomic.asm
; Implementation of functions for performing atomic operations.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
INCLUDE registers.inc
_TEXT SEGMENT
; --------- FUNCTIONS ---------------------------------------------------------
; See "parutil.h" for documentation.
parutilAtomicAdd8 PROC PUBLIC
lock add BYTE PTR [r64_param1], r8_param2
ret
parutilAtomicAdd8 ENDP
; ---------
parutilAtomicAdd16 PROC PUBLIC
lock add WORD PTR [r64_param1], r16_param2
ret
parutilAtomicAdd16 ENDP
; ---------
parutilAtomicAdd32 PROC PUBLIC
lock add DWORD PTR [r64_param1], r32_param2
ret
parutilAtomicAdd32 ENDP
; ---------
parutilAtomicAdd64 PROC PUBLIC
lock add QWORD PTR [r64_param1], r64_param2
ret
parutilAtomicAdd64 ENDP
; ---------
parutilAtomicExchange8 PROC PUBLIC
mov r8_retval, r8_param2
xchg BYTE PTR [r64_param1], r8_retval
ret
parutilAtomicExchange8 ENDP
; ---------
parutilAtomicExchange16 PROC PUBLIC
mov r16_retval, r16_param2
xchg WORD PTR [r64_param1], r16_retval
ret
parutilAtomicExchange16 ENDP
; ---------
parutilAtomicExchange32 PROC PUBLIC
mov r32_retval, r32_param2
xchg DWORD PTR [r64_param1], r32_retval
ret
parutilAtomicExchange32 ENDP
; ---------
parutilAtomicExchange64 PROC PUBLIC
mov r64_retval, r64_param2
xchg QWORD PTR [r64_param1], r64_retval
ret
parutilAtomicExchange64 ENDP
; ---------
parutilAtomicExchangeAdd8 PROC PUBLIC
mov r8_retval, r8_param2
lock xadd BYTE PTR [r64_param1], r8_retval
ret
parutilAtomicExchangeAdd8 ENDP
; ---------
parutilAtomicExchangeAdd16 PROC PUBLIC
mov r16_retval, r16_param2
lock xadd WORD PTR [r64_param1], r16_retval
ret
parutilAtomicExchangeAdd16 ENDP
; ---------
parutilAtomicExchangeAdd32 PROC PUBLIC
mov r32_retval, r32_param2
lock xadd DWORD PTR [r64_param1], r32_retval
ret
parutilAtomicExchangeAdd32 ENDP
; ---------
parutilAtomicExchangeAdd64 PROC PUBLIC
mov r64_retval, r64_param2
lock xadd QWORD PTR [r64_param1], r64_retval
ret
parutilAtomicExchangeAdd64 ENDP
_TEXT ENDS
END
|
; A169211: Number of reduced words of length n in Coxeter group on 6 generators S_i with relations (S_i)^2 = (S_i S_j)^28 = I.
; 1,6,30,150,750,3750,18750,93750,468750,2343750,11718750,58593750,292968750,1464843750,7324218750,36621093750,183105468750,915527343750,4577636718750,22888183593750,114440917968750,572204589843750
mov $1,5
pow $1,$0
mul $1,6
div $1,5
mov $0,$1
|
; A098117: a(n) = 5^(prime(n) - 1) + 5^prime(n) - 1.
; 29,149,3749,93749,58593749,1464843749,915527343749,22888183593749,14305114746093749,223517417907714843749,5587935447692871093749,87311491370201110839843749,54569682106375694274902343749,1364242052659392356872558593749
seq $0,6005 ; The odd prime numbers together with 1.
mov $1,5
pow $1,$0
div $1,2
mul $1,24
div $1,1200
mul $1,120
add $1,29
mov $0,$1
|
_echo: file format elf32-i386
Disassembly of section .text:
00000000 <main>:
#include "stat.h"
#include "user.h"
int
main(int argc, char *argv[])
{
0: 8d 4c 24 04 lea 0x4(%esp),%ecx
4: 83 e4 f0 and $0xfffffff0,%esp
7: ff 71 fc pushl -0x4(%ecx)
a: 55 push %ebp
b: 89 e5 mov %esp,%ebp
d: 57 push %edi
e: 56 push %esi
f: 53 push %ebx
10: 51 push %ecx
11: 83 ec 08 sub $0x8,%esp
14: 8b 31 mov (%ecx),%esi
16: 8b 79 04 mov 0x4(%ecx),%edi
int i;
for(i = 1; i < argc; i++)
19: 83 fe 01 cmp $0x1,%esi
1c: 7e 41 jle 5f <main+0x5f>
1e: bb 01 00 00 00 mov $0x1,%ebx
23: eb 1b jmp 40 <main+0x40>
25: 8d 76 00 lea 0x0(%esi),%esi
printf(1, "%s%s", argv[i], i+1 < argc ? " " : "\n");
28: 68 20 07 00 00 push $0x720
2d: ff 74 9f fc pushl -0x4(%edi,%ebx,4)
31: 68 22 07 00 00 push $0x722
36: 6a 01 push $0x1
38: e8 c3 03 00 00 call 400 <printf>
3d: 83 c4 10 add $0x10,%esp
40: 83 c3 01 add $0x1,%ebx
43: 39 de cmp %ebx,%esi
45: 75 e1 jne 28 <main+0x28>
47: 68 27 07 00 00 push $0x727
4c: ff 74 b7 fc pushl -0x4(%edi,%esi,4)
50: 68 22 07 00 00 push $0x722
55: 6a 01 push $0x1
57: e8 a4 03 00 00 call 400 <printf>
5c: 83 c4 10 add $0x10,%esp
exit();
5f: e8 4e 02 00 00 call 2b2 <exit>
64: 66 90 xchg %ax,%ax
66: 66 90 xchg %ax,%ax
68: 66 90 xchg %ax,%ax
6a: 66 90 xchg %ax,%ax
6c: 66 90 xchg %ax,%ax
6e: 66 90 xchg %ax,%ax
00000070 <strcpy>:
#include "user.h"
#include "x86.h"
char*
strcpy(char *s, const char *t)
{
70: 55 push %ebp
71: 89 e5 mov %esp,%ebp
73: 53 push %ebx
74: 8b 45 08 mov 0x8(%ebp),%eax
77: 8b 4d 0c mov 0xc(%ebp),%ecx
char *os;
os = s;
while((*s++ = *t++) != 0)
7a: 89 c2 mov %eax,%edx
7c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
80: 83 c1 01 add $0x1,%ecx
83: 0f b6 59 ff movzbl -0x1(%ecx),%ebx
87: 83 c2 01 add $0x1,%edx
8a: 84 db test %bl,%bl
8c: 88 5a ff mov %bl,-0x1(%edx)
8f: 75 ef jne 80 <strcpy+0x10>
;
return os;
}
91: 5b pop %ebx
92: 5d pop %ebp
93: c3 ret
94: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
9a: 8d bf 00 00 00 00 lea 0x0(%edi),%edi
000000a0 <strcmp>:
int
strcmp(const char *p, const char *q)
{
a0: 55 push %ebp
a1: 89 e5 mov %esp,%ebp
a3: 56 push %esi
a4: 53 push %ebx
a5: 8b 55 08 mov 0x8(%ebp),%edx
a8: 8b 4d 0c mov 0xc(%ebp),%ecx
while(*p && *p == *q)
ab: 0f b6 02 movzbl (%edx),%eax
ae: 0f b6 19 movzbl (%ecx),%ebx
b1: 84 c0 test %al,%al
b3: 75 1e jne d3 <strcmp+0x33>
b5: eb 29 jmp e0 <strcmp+0x40>
b7: 89 f6 mov %esi,%esi
b9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
p++, q++;
c0: 83 c2 01 add $0x1,%edx
while(*p && *p == *q)
c3: 0f b6 02 movzbl (%edx),%eax
p++, q++;
c6: 8d 71 01 lea 0x1(%ecx),%esi
while(*p && *p == *q)
c9: 0f b6 59 01 movzbl 0x1(%ecx),%ebx
cd: 84 c0 test %al,%al
cf: 74 0f je e0 <strcmp+0x40>
d1: 89 f1 mov %esi,%ecx
d3: 38 d8 cmp %bl,%al
d5: 74 e9 je c0 <strcmp+0x20>
return (uchar)*p - (uchar)*q;
d7: 29 d8 sub %ebx,%eax
}
d9: 5b pop %ebx
da: 5e pop %esi
db: 5d pop %ebp
dc: c3 ret
dd: 8d 76 00 lea 0x0(%esi),%esi
while(*p && *p == *q)
e0: 31 c0 xor %eax,%eax
return (uchar)*p - (uchar)*q;
e2: 29 d8 sub %ebx,%eax
}
e4: 5b pop %ebx
e5: 5e pop %esi
e6: 5d pop %ebp
e7: c3 ret
e8: 90 nop
e9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
000000f0 <strlen>:
uint
strlen(const char *s)
{
f0: 55 push %ebp
f1: 89 e5 mov %esp,%ebp
f3: 8b 4d 08 mov 0x8(%ebp),%ecx
int n;
for(n = 0; s[n]; n++)
f6: 80 39 00 cmpb $0x0,(%ecx)
f9: 74 12 je 10d <strlen+0x1d>
fb: 31 d2 xor %edx,%edx
fd: 8d 76 00 lea 0x0(%esi),%esi
100: 83 c2 01 add $0x1,%edx
103: 80 3c 11 00 cmpb $0x0,(%ecx,%edx,1)
107: 89 d0 mov %edx,%eax
109: 75 f5 jne 100 <strlen+0x10>
;
return n;
}
10b: 5d pop %ebp
10c: c3 ret
for(n = 0; s[n]; n++)
10d: 31 c0 xor %eax,%eax
}
10f: 5d pop %ebp
110: c3 ret
111: eb 0d jmp 120 <memset>
113: 90 nop
114: 90 nop
115: 90 nop
116: 90 nop
117: 90 nop
118: 90 nop
119: 90 nop
11a: 90 nop
11b: 90 nop
11c: 90 nop
11d: 90 nop
11e: 90 nop
11f: 90 nop
00000120 <memset>:
void*
memset(void *dst, int c, uint n)
{
120: 55 push %ebp
121: 89 e5 mov %esp,%ebp
123: 57 push %edi
124: 8b 55 08 mov 0x8(%ebp),%edx
}
static inline void
stosb(void *addr, int data, int cnt)
{
asm volatile("cld; rep stosb" :
127: 8b 4d 10 mov 0x10(%ebp),%ecx
12a: 8b 45 0c mov 0xc(%ebp),%eax
12d: 89 d7 mov %edx,%edi
12f: fc cld
130: f3 aa rep stos %al,%es:(%edi)
stosb(dst, c, n);
return dst;
}
132: 89 d0 mov %edx,%eax
134: 5f pop %edi
135: 5d pop %ebp
136: c3 ret
137: 89 f6 mov %esi,%esi
139: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
00000140 <strchr>:
char*
strchr(const char *s, char c)
{
140: 55 push %ebp
141: 89 e5 mov %esp,%ebp
143: 53 push %ebx
144: 8b 45 08 mov 0x8(%ebp),%eax
147: 8b 5d 0c mov 0xc(%ebp),%ebx
for(; *s; s++)
14a: 0f b6 10 movzbl (%eax),%edx
14d: 84 d2 test %dl,%dl
14f: 74 1d je 16e <strchr+0x2e>
if(*s == c)
151: 38 d3 cmp %dl,%bl
153: 89 d9 mov %ebx,%ecx
155: 75 0d jne 164 <strchr+0x24>
157: eb 17 jmp 170 <strchr+0x30>
159: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
160: 38 ca cmp %cl,%dl
162: 74 0c je 170 <strchr+0x30>
for(; *s; s++)
164: 83 c0 01 add $0x1,%eax
167: 0f b6 10 movzbl (%eax),%edx
16a: 84 d2 test %dl,%dl
16c: 75 f2 jne 160 <strchr+0x20>
return (char*)s;
return 0;
16e: 31 c0 xor %eax,%eax
}
170: 5b pop %ebx
171: 5d pop %ebp
172: c3 ret
173: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
179: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
00000180 <gets>:
char*
gets(char *buf, int max)
{
180: 55 push %ebp
181: 89 e5 mov %esp,%ebp
183: 57 push %edi
184: 56 push %esi
185: 53 push %ebx
int i, cc;
char c;
for(i=0; i+1 < max; ){
186: 31 f6 xor %esi,%esi
cc = read(0, &c, 1);
188: 8d 7d e7 lea -0x19(%ebp),%edi
{
18b: 83 ec 1c sub $0x1c,%esp
for(i=0; i+1 < max; ){
18e: eb 29 jmp 1b9 <gets+0x39>
cc = read(0, &c, 1);
190: 83 ec 04 sub $0x4,%esp
193: 6a 01 push $0x1
195: 57 push %edi
196: 6a 00 push $0x0
198: e8 2d 01 00 00 call 2ca <read>
if(cc < 1)
19d: 83 c4 10 add $0x10,%esp
1a0: 85 c0 test %eax,%eax
1a2: 7e 1d jle 1c1 <gets+0x41>
break;
buf[i++] = c;
1a4: 0f b6 45 e7 movzbl -0x19(%ebp),%eax
1a8: 8b 55 08 mov 0x8(%ebp),%edx
1ab: 89 de mov %ebx,%esi
if(c == '\n' || c == '\r')
1ad: 3c 0a cmp $0xa,%al
buf[i++] = c;
1af: 88 44 1a ff mov %al,-0x1(%edx,%ebx,1)
if(c == '\n' || c == '\r')
1b3: 74 1b je 1d0 <gets+0x50>
1b5: 3c 0d cmp $0xd,%al
1b7: 74 17 je 1d0 <gets+0x50>
for(i=0; i+1 < max; ){
1b9: 8d 5e 01 lea 0x1(%esi),%ebx
1bc: 3b 5d 0c cmp 0xc(%ebp),%ebx
1bf: 7c cf jl 190 <gets+0x10>
break;
}
buf[i] = '\0';
1c1: 8b 45 08 mov 0x8(%ebp),%eax
1c4: c6 04 30 00 movb $0x0,(%eax,%esi,1)
return buf;
}
1c8: 8d 65 f4 lea -0xc(%ebp),%esp
1cb: 5b pop %ebx
1cc: 5e pop %esi
1cd: 5f pop %edi
1ce: 5d pop %ebp
1cf: c3 ret
buf[i] = '\0';
1d0: 8b 45 08 mov 0x8(%ebp),%eax
for(i=0; i+1 < max; ){
1d3: 89 de mov %ebx,%esi
buf[i] = '\0';
1d5: c6 04 30 00 movb $0x0,(%eax,%esi,1)
}
1d9: 8d 65 f4 lea -0xc(%ebp),%esp
1dc: 5b pop %ebx
1dd: 5e pop %esi
1de: 5f pop %edi
1df: 5d pop %ebp
1e0: c3 ret
1e1: eb 0d jmp 1f0 <stat>
1e3: 90 nop
1e4: 90 nop
1e5: 90 nop
1e6: 90 nop
1e7: 90 nop
1e8: 90 nop
1e9: 90 nop
1ea: 90 nop
1eb: 90 nop
1ec: 90 nop
1ed: 90 nop
1ee: 90 nop
1ef: 90 nop
000001f0 <stat>:
int
stat(const char *n, struct stat *st)
{
1f0: 55 push %ebp
1f1: 89 e5 mov %esp,%ebp
1f3: 56 push %esi
1f4: 53 push %ebx
int fd;
int r;
fd = open(n, O_RDONLY);
1f5: 83 ec 08 sub $0x8,%esp
1f8: 6a 00 push $0x0
1fa: ff 75 08 pushl 0x8(%ebp)
1fd: e8 f0 00 00 00 call 2f2 <open>
if(fd < 0)
202: 83 c4 10 add $0x10,%esp
205: 85 c0 test %eax,%eax
207: 78 27 js 230 <stat+0x40>
return -1;
r = fstat(fd, st);
209: 83 ec 08 sub $0x8,%esp
20c: ff 75 0c pushl 0xc(%ebp)
20f: 89 c3 mov %eax,%ebx
211: 50 push %eax
212: e8 f3 00 00 00 call 30a <fstat>
close(fd);
217: 89 1c 24 mov %ebx,(%esp)
r = fstat(fd, st);
21a: 89 c6 mov %eax,%esi
close(fd);
21c: e8 b9 00 00 00 call 2da <close>
return r;
221: 83 c4 10 add $0x10,%esp
}
224: 8d 65 f8 lea -0x8(%ebp),%esp
227: 89 f0 mov %esi,%eax
229: 5b pop %ebx
22a: 5e pop %esi
22b: 5d pop %ebp
22c: c3 ret
22d: 8d 76 00 lea 0x0(%esi),%esi
return -1;
230: be ff ff ff ff mov $0xffffffff,%esi
235: eb ed jmp 224 <stat+0x34>
237: 89 f6 mov %esi,%esi
239: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
00000240 <atoi>:
int
atoi(const char *s)
{
240: 55 push %ebp
241: 89 e5 mov %esp,%ebp
243: 53 push %ebx
244: 8b 4d 08 mov 0x8(%ebp),%ecx
int n;
n = 0;
while('0' <= *s && *s <= '9')
247: 0f be 11 movsbl (%ecx),%edx
24a: 8d 42 d0 lea -0x30(%edx),%eax
24d: 3c 09 cmp $0x9,%al
24f: b8 00 00 00 00 mov $0x0,%eax
254: 77 1f ja 275 <atoi+0x35>
256: 8d 76 00 lea 0x0(%esi),%esi
259: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
n = n*10 + *s++ - '0';
260: 8d 04 80 lea (%eax,%eax,4),%eax
263: 83 c1 01 add $0x1,%ecx
266: 8d 44 42 d0 lea -0x30(%edx,%eax,2),%eax
while('0' <= *s && *s <= '9')
26a: 0f be 11 movsbl (%ecx),%edx
26d: 8d 5a d0 lea -0x30(%edx),%ebx
270: 80 fb 09 cmp $0x9,%bl
273: 76 eb jbe 260 <atoi+0x20>
return n;
}
275: 5b pop %ebx
276: 5d pop %ebp
277: c3 ret
278: 90 nop
279: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
00000280 <memmove>:
void*
memmove(void *vdst, const void *vsrc, int n)
{
280: 55 push %ebp
281: 89 e5 mov %esp,%ebp
283: 56 push %esi
284: 53 push %ebx
285: 8b 5d 10 mov 0x10(%ebp),%ebx
288: 8b 45 08 mov 0x8(%ebp),%eax
28b: 8b 75 0c mov 0xc(%ebp),%esi
char *dst;
const char *src;
dst = vdst;
src = vsrc;
while(n-- > 0)
28e: 85 db test %ebx,%ebx
290: 7e 14 jle 2a6 <memmove+0x26>
292: 31 d2 xor %edx,%edx
294: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
*dst++ = *src++;
298: 0f b6 0c 16 movzbl (%esi,%edx,1),%ecx
29c: 88 0c 10 mov %cl,(%eax,%edx,1)
29f: 83 c2 01 add $0x1,%edx
while(n-- > 0)
2a2: 39 da cmp %ebx,%edx
2a4: 75 f2 jne 298 <memmove+0x18>
return vdst;
}
2a6: 5b pop %ebx
2a7: 5e pop %esi
2a8: 5d pop %ebp
2a9: c3 ret
000002aa <fork>:
name: \
movl $SYS_ ## name, %eax; \
int $T_SYSCALL; \
ret
SYSCALL(fork)
2aa: b8 01 00 00 00 mov $0x1,%eax
2af: cd 40 int $0x40
2b1: c3 ret
000002b2 <exit>:
SYSCALL(exit)
2b2: b8 02 00 00 00 mov $0x2,%eax
2b7: cd 40 int $0x40
2b9: c3 ret
000002ba <wait>:
SYSCALL(wait)
2ba: b8 03 00 00 00 mov $0x3,%eax
2bf: cd 40 int $0x40
2c1: c3 ret
000002c2 <pipe>:
SYSCALL(pipe)
2c2: b8 04 00 00 00 mov $0x4,%eax
2c7: cd 40 int $0x40
2c9: c3 ret
000002ca <read>:
SYSCALL(read)
2ca: b8 05 00 00 00 mov $0x5,%eax
2cf: cd 40 int $0x40
2d1: c3 ret
000002d2 <write>:
SYSCALL(write)
2d2: b8 10 00 00 00 mov $0x10,%eax
2d7: cd 40 int $0x40
2d9: c3 ret
000002da <close>:
SYSCALL(close)
2da: b8 15 00 00 00 mov $0x15,%eax
2df: cd 40 int $0x40
2e1: c3 ret
000002e2 <kill>:
SYSCALL(kill)
2e2: b8 06 00 00 00 mov $0x6,%eax
2e7: cd 40 int $0x40
2e9: c3 ret
000002ea <exec>:
SYSCALL(exec)
2ea: b8 07 00 00 00 mov $0x7,%eax
2ef: cd 40 int $0x40
2f1: c3 ret
000002f2 <open>:
SYSCALL(open)
2f2: b8 0f 00 00 00 mov $0xf,%eax
2f7: cd 40 int $0x40
2f9: c3 ret
000002fa <mknod>:
SYSCALL(mknod)
2fa: b8 11 00 00 00 mov $0x11,%eax
2ff: cd 40 int $0x40
301: c3 ret
00000302 <unlink>:
SYSCALL(unlink)
302: b8 12 00 00 00 mov $0x12,%eax
307: cd 40 int $0x40
309: c3 ret
0000030a <fstat>:
SYSCALL(fstat)
30a: b8 08 00 00 00 mov $0x8,%eax
30f: cd 40 int $0x40
311: c3 ret
00000312 <link>:
SYSCALL(link)
312: b8 13 00 00 00 mov $0x13,%eax
317: cd 40 int $0x40
319: c3 ret
0000031a <mkdir>:
SYSCALL(mkdir)
31a: b8 14 00 00 00 mov $0x14,%eax
31f: cd 40 int $0x40
321: c3 ret
00000322 <chdir>:
SYSCALL(chdir)
322: b8 09 00 00 00 mov $0x9,%eax
327: cd 40 int $0x40
329: c3 ret
0000032a <dup>:
SYSCALL(dup)
32a: b8 0a 00 00 00 mov $0xa,%eax
32f: cd 40 int $0x40
331: c3 ret
00000332 <getpid>:
SYSCALL(getpid)
332: b8 0b 00 00 00 mov $0xb,%eax
337: cd 40 int $0x40
339: c3 ret
0000033a <sbrk>:
SYSCALL(sbrk)
33a: b8 0c 00 00 00 mov $0xc,%eax
33f: cd 40 int $0x40
341: c3 ret
00000342 <sleep>:
SYSCALL(sleep)
342: b8 0d 00 00 00 mov $0xd,%eax
347: cd 40 int $0x40
349: c3 ret
0000034a <uptime>:
SYSCALL(uptime)
34a: b8 0e 00 00 00 mov $0xe,%eax
34f: cd 40 int $0x40
351: c3 ret
352: 66 90 xchg %ax,%ax
354: 66 90 xchg %ax,%ax
356: 66 90 xchg %ax,%ax
358: 66 90 xchg %ax,%ax
35a: 66 90 xchg %ax,%ax
35c: 66 90 xchg %ax,%ax
35e: 66 90 xchg %ax,%ax
00000360 <printint>:
write(fd, &c, 1);
}
static void
printint(int fd, int xx, int base, int sgn)
{
360: 55 push %ebp
361: 89 e5 mov %esp,%ebp
363: 57 push %edi
364: 56 push %esi
365: 53 push %ebx
366: 89 c6 mov %eax,%esi
368: 83 ec 3c sub $0x3c,%esp
char buf[16];
int i, neg;
uint x;
neg = 0;
if(sgn && xx < 0){
36b: 8b 5d 08 mov 0x8(%ebp),%ebx
36e: 85 db test %ebx,%ebx
370: 74 7e je 3f0 <printint+0x90>
372: 89 d0 mov %edx,%eax
374: c1 e8 1f shr $0x1f,%eax
377: 84 c0 test %al,%al
379: 74 75 je 3f0 <printint+0x90>
neg = 1;
x = -xx;
37b: 89 d0 mov %edx,%eax
neg = 1;
37d: c7 45 c4 01 00 00 00 movl $0x1,-0x3c(%ebp)
x = -xx;
384: f7 d8 neg %eax
386: 89 75 c0 mov %esi,-0x40(%ebp)
} else {
x = xx;
}
i = 0;
389: 31 ff xor %edi,%edi
38b: 8d 5d d7 lea -0x29(%ebp),%ebx
38e: 89 ce mov %ecx,%esi
390: eb 08 jmp 39a <printint+0x3a>
392: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
do{
buf[i++] = digits[x % base];
398: 89 cf mov %ecx,%edi
39a: 31 d2 xor %edx,%edx
39c: 8d 4f 01 lea 0x1(%edi),%ecx
39f: f7 f6 div %esi
3a1: 0f b6 92 30 07 00 00 movzbl 0x730(%edx),%edx
}while((x /= base) != 0);
3a8: 85 c0 test %eax,%eax
buf[i++] = digits[x % base];
3aa: 88 14 0b mov %dl,(%ebx,%ecx,1)
}while((x /= base) != 0);
3ad: 75 e9 jne 398 <printint+0x38>
if(neg)
3af: 8b 45 c4 mov -0x3c(%ebp),%eax
3b2: 8b 75 c0 mov -0x40(%ebp),%esi
3b5: 85 c0 test %eax,%eax
3b7: 74 08 je 3c1 <printint+0x61>
buf[i++] = '-';
3b9: c6 44 0d d8 2d movb $0x2d,-0x28(%ebp,%ecx,1)
3be: 8d 4f 02 lea 0x2(%edi),%ecx
while(--i >= 0)
3c1: 8d 79 ff lea -0x1(%ecx),%edi
3c4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
3c8: 0f b6 44 3d d8 movzbl -0x28(%ebp,%edi,1),%eax
write(fd, &c, 1);
3cd: 83 ec 04 sub $0x4,%esp
while(--i >= 0)
3d0: 83 ef 01 sub $0x1,%edi
write(fd, &c, 1);
3d3: 6a 01 push $0x1
3d5: 53 push %ebx
3d6: 56 push %esi
3d7: 88 45 d7 mov %al,-0x29(%ebp)
3da: e8 f3 fe ff ff call 2d2 <write>
while(--i >= 0)
3df: 83 c4 10 add $0x10,%esp
3e2: 83 ff ff cmp $0xffffffff,%edi
3e5: 75 e1 jne 3c8 <printint+0x68>
putc(fd, buf[i]);
}
3e7: 8d 65 f4 lea -0xc(%ebp),%esp
3ea: 5b pop %ebx
3eb: 5e pop %esi
3ec: 5f pop %edi
3ed: 5d pop %ebp
3ee: c3 ret
3ef: 90 nop
x = xx;
3f0: 89 d0 mov %edx,%eax
neg = 0;
3f2: c7 45 c4 00 00 00 00 movl $0x0,-0x3c(%ebp)
3f9: eb 8b jmp 386 <printint+0x26>
3fb: 90 nop
3fc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
00000400 <printf>:
// Print to the given fd. Only understands %d, %x, %p, %s.
void
printf(int fd, const char *fmt, ...)
{
400: 55 push %ebp
401: 89 e5 mov %esp,%ebp
403: 57 push %edi
404: 56 push %esi
405: 53 push %ebx
int c, i, state;
uint *ap;
state = 0;
ap = (uint*)(void*)&fmt + 1;
for(i = 0; fmt[i]; i++){
406: 8d 45 10 lea 0x10(%ebp),%eax
{
409: 83 ec 2c sub $0x2c,%esp
for(i = 0; fmt[i]; i++){
40c: 8b 75 0c mov 0xc(%ebp),%esi
{
40f: 8b 7d 08 mov 0x8(%ebp),%edi
for(i = 0; fmt[i]; i++){
412: 89 45 d0 mov %eax,-0x30(%ebp)
415: 0f b6 1e movzbl (%esi),%ebx
418: 83 c6 01 add $0x1,%esi
41b: 84 db test %bl,%bl
41d: 0f 84 b0 00 00 00 je 4d3 <printf+0xd3>
423: 31 d2 xor %edx,%edx
425: eb 39 jmp 460 <printf+0x60>
427: 89 f6 mov %esi,%esi
429: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
c = fmt[i] & 0xff;
if(state == 0){
if(c == '%'){
430: 83 f8 25 cmp $0x25,%eax
433: 89 55 d4 mov %edx,-0x2c(%ebp)
state = '%';
436: ba 25 00 00 00 mov $0x25,%edx
if(c == '%'){
43b: 74 18 je 455 <printf+0x55>
write(fd, &c, 1);
43d: 8d 45 e2 lea -0x1e(%ebp),%eax
440: 83 ec 04 sub $0x4,%esp
443: 88 5d e2 mov %bl,-0x1e(%ebp)
446: 6a 01 push $0x1
448: 50 push %eax
449: 57 push %edi
44a: e8 83 fe ff ff call 2d2 <write>
44f: 8b 55 d4 mov -0x2c(%ebp),%edx
452: 83 c4 10 add $0x10,%esp
455: 83 c6 01 add $0x1,%esi
for(i = 0; fmt[i]; i++){
458: 0f b6 5e ff movzbl -0x1(%esi),%ebx
45c: 84 db test %bl,%bl
45e: 74 73 je 4d3 <printf+0xd3>
if(state == 0){
460: 85 d2 test %edx,%edx
c = fmt[i] & 0xff;
462: 0f be cb movsbl %bl,%ecx
465: 0f b6 c3 movzbl %bl,%eax
if(state == 0){
468: 74 c6 je 430 <printf+0x30>
} else {
putc(fd, c);
}
} else if(state == '%'){
46a: 83 fa 25 cmp $0x25,%edx
46d: 75 e6 jne 455 <printf+0x55>
if(c == 'd'){
46f: 83 f8 64 cmp $0x64,%eax
472: 0f 84 f8 00 00 00 je 570 <printf+0x170>
printint(fd, *ap, 10, 1);
ap++;
} else if(c == 'x' || c == 'p'){
478: 81 e1 f7 00 00 00 and $0xf7,%ecx
47e: 83 f9 70 cmp $0x70,%ecx
481: 74 5d je 4e0 <printf+0xe0>
printint(fd, *ap, 16, 0);
ap++;
} else if(c == 's'){
483: 83 f8 73 cmp $0x73,%eax
486: 0f 84 84 00 00 00 je 510 <printf+0x110>
s = "(null)";
while(*s != 0){
putc(fd, *s);
s++;
}
} else if(c == 'c'){
48c: 83 f8 63 cmp $0x63,%eax
48f: 0f 84 ea 00 00 00 je 57f <printf+0x17f>
putc(fd, *ap);
ap++;
} else if(c == '%'){
495: 83 f8 25 cmp $0x25,%eax
498: 0f 84 c2 00 00 00 je 560 <printf+0x160>
write(fd, &c, 1);
49e: 8d 45 e7 lea -0x19(%ebp),%eax
4a1: 83 ec 04 sub $0x4,%esp
4a4: c6 45 e7 25 movb $0x25,-0x19(%ebp)
4a8: 6a 01 push $0x1
4aa: 50 push %eax
4ab: 57 push %edi
4ac: e8 21 fe ff ff call 2d2 <write>
4b1: 83 c4 0c add $0xc,%esp
4b4: 8d 45 e6 lea -0x1a(%ebp),%eax
4b7: 88 5d e6 mov %bl,-0x1a(%ebp)
4ba: 6a 01 push $0x1
4bc: 50 push %eax
4bd: 57 push %edi
4be: 83 c6 01 add $0x1,%esi
4c1: e8 0c fe ff ff call 2d2 <write>
for(i = 0; fmt[i]; i++){
4c6: 0f b6 5e ff movzbl -0x1(%esi),%ebx
write(fd, &c, 1);
4ca: 83 c4 10 add $0x10,%esp
} else {
// Unknown % sequence. Print it to draw attention.
putc(fd, '%');
putc(fd, c);
}
state = 0;
4cd: 31 d2 xor %edx,%edx
for(i = 0; fmt[i]; i++){
4cf: 84 db test %bl,%bl
4d1: 75 8d jne 460 <printf+0x60>
}
}
}
4d3: 8d 65 f4 lea -0xc(%ebp),%esp
4d6: 5b pop %ebx
4d7: 5e pop %esi
4d8: 5f pop %edi
4d9: 5d pop %ebp
4da: c3 ret
4db: 90 nop
4dc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
printint(fd, *ap, 16, 0);
4e0: 83 ec 0c sub $0xc,%esp
4e3: b9 10 00 00 00 mov $0x10,%ecx
4e8: 6a 00 push $0x0
4ea: 8b 5d d0 mov -0x30(%ebp),%ebx
4ed: 89 f8 mov %edi,%eax
4ef: 8b 13 mov (%ebx),%edx
4f1: e8 6a fe ff ff call 360 <printint>
ap++;
4f6: 89 d8 mov %ebx,%eax
4f8: 83 c4 10 add $0x10,%esp
state = 0;
4fb: 31 d2 xor %edx,%edx
ap++;
4fd: 83 c0 04 add $0x4,%eax
500: 89 45 d0 mov %eax,-0x30(%ebp)
503: e9 4d ff ff ff jmp 455 <printf+0x55>
508: 90 nop
509: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
s = (char*)*ap;
510: 8b 45 d0 mov -0x30(%ebp),%eax
513: 8b 18 mov (%eax),%ebx
ap++;
515: 83 c0 04 add $0x4,%eax
518: 89 45 d0 mov %eax,-0x30(%ebp)
if(s == 0)
51b: 85 db test %ebx,%ebx
51d: 74 7c je 59b <printf+0x19b>
while(*s != 0){
51f: 0f b6 03 movzbl (%ebx),%eax
522: 84 c0 test %al,%al
524: 74 29 je 54f <printf+0x14f>
526: 8d 76 00 lea 0x0(%esi),%esi
529: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
530: 88 45 e3 mov %al,-0x1d(%ebp)
write(fd, &c, 1);
533: 8d 45 e3 lea -0x1d(%ebp),%eax
536: 83 ec 04 sub $0x4,%esp
539: 6a 01 push $0x1
s++;
53b: 83 c3 01 add $0x1,%ebx
write(fd, &c, 1);
53e: 50 push %eax
53f: 57 push %edi
540: e8 8d fd ff ff call 2d2 <write>
while(*s != 0){
545: 0f b6 03 movzbl (%ebx),%eax
548: 83 c4 10 add $0x10,%esp
54b: 84 c0 test %al,%al
54d: 75 e1 jne 530 <printf+0x130>
state = 0;
54f: 31 d2 xor %edx,%edx
551: e9 ff fe ff ff jmp 455 <printf+0x55>
556: 8d 76 00 lea 0x0(%esi),%esi
559: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
write(fd, &c, 1);
560: 83 ec 04 sub $0x4,%esp
563: 88 5d e5 mov %bl,-0x1b(%ebp)
566: 8d 45 e5 lea -0x1b(%ebp),%eax
569: 6a 01 push $0x1
56b: e9 4c ff ff ff jmp 4bc <printf+0xbc>
printint(fd, *ap, 10, 1);
570: 83 ec 0c sub $0xc,%esp
573: b9 0a 00 00 00 mov $0xa,%ecx
578: 6a 01 push $0x1
57a: e9 6b ff ff ff jmp 4ea <printf+0xea>
putc(fd, *ap);
57f: 8b 5d d0 mov -0x30(%ebp),%ebx
write(fd, &c, 1);
582: 83 ec 04 sub $0x4,%esp
putc(fd, *ap);
585: 8b 03 mov (%ebx),%eax
write(fd, &c, 1);
587: 6a 01 push $0x1
putc(fd, *ap);
589: 88 45 e4 mov %al,-0x1c(%ebp)
write(fd, &c, 1);
58c: 8d 45 e4 lea -0x1c(%ebp),%eax
58f: 50 push %eax
590: 57 push %edi
591: e8 3c fd ff ff call 2d2 <write>
596: e9 5b ff ff ff jmp 4f6 <printf+0xf6>
while(*s != 0){
59b: b8 28 00 00 00 mov $0x28,%eax
s = "(null)";
5a0: bb 29 07 00 00 mov $0x729,%ebx
5a5: eb 89 jmp 530 <printf+0x130>
5a7: 66 90 xchg %ax,%ax
5a9: 66 90 xchg %ax,%ax
5ab: 66 90 xchg %ax,%ax
5ad: 66 90 xchg %ax,%ax
5af: 90 nop
000005b0 <free>:
static Header base;
static Header *freep;
void
free(void *ap)
{
5b0: 55 push %ebp
Header *bp, *p;
bp = (Header*)ap - 1;
for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
5b1: a1 d4 09 00 00 mov 0x9d4,%eax
{
5b6: 89 e5 mov %esp,%ebp
5b8: 57 push %edi
5b9: 56 push %esi
5ba: 53 push %ebx
5bb: 8b 5d 08 mov 0x8(%ebp),%ebx
if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
5be: 8b 10 mov (%eax),%edx
bp = (Header*)ap - 1;
5c0: 8d 4b f8 lea -0x8(%ebx),%ecx
for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
5c3: 39 c8 cmp %ecx,%eax
5c5: 73 19 jae 5e0 <free+0x30>
5c7: 89 f6 mov %esi,%esi
5c9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
5d0: 39 d1 cmp %edx,%ecx
5d2: 72 1c jb 5f0 <free+0x40>
if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
5d4: 39 d0 cmp %edx,%eax
5d6: 73 18 jae 5f0 <free+0x40>
{
5d8: 89 d0 mov %edx,%eax
for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
5da: 39 c8 cmp %ecx,%eax
if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
5dc: 8b 10 mov (%eax),%edx
for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
5de: 72 f0 jb 5d0 <free+0x20>
if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
5e0: 39 d0 cmp %edx,%eax
5e2: 72 f4 jb 5d8 <free+0x28>
5e4: 39 d1 cmp %edx,%ecx
5e6: 73 f0 jae 5d8 <free+0x28>
5e8: 90 nop
5e9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
break;
if(bp + bp->s.size == p->s.ptr){
5f0: 8b 73 fc mov -0x4(%ebx),%esi
5f3: 8d 3c f1 lea (%ecx,%esi,8),%edi
5f6: 39 fa cmp %edi,%edx
5f8: 74 19 je 613 <free+0x63>
bp->s.size += p->s.ptr->s.size;
bp->s.ptr = p->s.ptr->s.ptr;
} else
bp->s.ptr = p->s.ptr;
5fa: 89 53 f8 mov %edx,-0x8(%ebx)
if(p + p->s.size == bp){
5fd: 8b 50 04 mov 0x4(%eax),%edx
600: 8d 34 d0 lea (%eax,%edx,8),%esi
603: 39 f1 cmp %esi,%ecx
605: 74 23 je 62a <free+0x7a>
p->s.size += bp->s.size;
p->s.ptr = bp->s.ptr;
} else
p->s.ptr = bp;
607: 89 08 mov %ecx,(%eax)
freep = p;
609: a3 d4 09 00 00 mov %eax,0x9d4
}
60e: 5b pop %ebx
60f: 5e pop %esi
610: 5f pop %edi
611: 5d pop %ebp
612: c3 ret
bp->s.size += p->s.ptr->s.size;
613: 03 72 04 add 0x4(%edx),%esi
616: 89 73 fc mov %esi,-0x4(%ebx)
bp->s.ptr = p->s.ptr->s.ptr;
619: 8b 10 mov (%eax),%edx
61b: 8b 12 mov (%edx),%edx
61d: 89 53 f8 mov %edx,-0x8(%ebx)
if(p + p->s.size == bp){
620: 8b 50 04 mov 0x4(%eax),%edx
623: 8d 34 d0 lea (%eax,%edx,8),%esi
626: 39 f1 cmp %esi,%ecx
628: 75 dd jne 607 <free+0x57>
p->s.size += bp->s.size;
62a: 03 53 fc add -0x4(%ebx),%edx
freep = p;
62d: a3 d4 09 00 00 mov %eax,0x9d4
p->s.size += bp->s.size;
632: 89 50 04 mov %edx,0x4(%eax)
p->s.ptr = bp->s.ptr;
635: 8b 53 f8 mov -0x8(%ebx),%edx
638: 89 10 mov %edx,(%eax)
}
63a: 5b pop %ebx
63b: 5e pop %esi
63c: 5f pop %edi
63d: 5d pop %ebp
63e: c3 ret
63f: 90 nop
00000640 <malloc>:
return freep;
}
void*
malloc(uint nbytes)
{
640: 55 push %ebp
641: 89 e5 mov %esp,%ebp
643: 57 push %edi
644: 56 push %esi
645: 53 push %ebx
646: 83 ec 0c sub $0xc,%esp
Header *p, *prevp;
uint nunits;
nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
649: 8b 45 08 mov 0x8(%ebp),%eax
if((prevp = freep) == 0){
64c: 8b 15 d4 09 00 00 mov 0x9d4,%edx
nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
652: 8d 78 07 lea 0x7(%eax),%edi
655: c1 ef 03 shr $0x3,%edi
658: 83 c7 01 add $0x1,%edi
if((prevp = freep) == 0){
65b: 85 d2 test %edx,%edx
65d: 0f 84 93 00 00 00 je 6f6 <malloc+0xb6>
663: 8b 02 mov (%edx),%eax
665: 8b 48 04 mov 0x4(%eax),%ecx
base.s.ptr = freep = prevp = &base;
base.s.size = 0;
}
for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
if(p->s.size >= nunits){
668: 39 cf cmp %ecx,%edi
66a: 76 64 jbe 6d0 <malloc+0x90>
66c: 81 ff 00 10 00 00 cmp $0x1000,%edi
672: bb 00 10 00 00 mov $0x1000,%ebx
677: 0f 43 df cmovae %edi,%ebx
p = sbrk(nu * sizeof(Header));
67a: 8d 34 dd 00 00 00 00 lea 0x0(,%ebx,8),%esi
681: eb 0e jmp 691 <malloc+0x51>
683: 90 nop
684: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
688: 8b 02 mov (%edx),%eax
if(p->s.size >= nunits){
68a: 8b 48 04 mov 0x4(%eax),%ecx
68d: 39 cf cmp %ecx,%edi
68f: 76 3f jbe 6d0 <malloc+0x90>
p->s.size = nunits;
}
freep = prevp;
return (void*)(p + 1);
}
if(p == freep)
691: 39 05 d4 09 00 00 cmp %eax,0x9d4
697: 89 c2 mov %eax,%edx
699: 75 ed jne 688 <malloc+0x48>
p = sbrk(nu * sizeof(Header));
69b: 83 ec 0c sub $0xc,%esp
69e: 56 push %esi
69f: e8 96 fc ff ff call 33a <sbrk>
if(p == (char*)-1)
6a4: 83 c4 10 add $0x10,%esp
6a7: 83 f8 ff cmp $0xffffffff,%eax
6aa: 74 1c je 6c8 <malloc+0x88>
hp->s.size = nu;
6ac: 89 58 04 mov %ebx,0x4(%eax)
free((void*)(hp + 1));
6af: 83 ec 0c sub $0xc,%esp
6b2: 83 c0 08 add $0x8,%eax
6b5: 50 push %eax
6b6: e8 f5 fe ff ff call 5b0 <free>
return freep;
6bb: 8b 15 d4 09 00 00 mov 0x9d4,%edx
if((p = morecore(nunits)) == 0)
6c1: 83 c4 10 add $0x10,%esp
6c4: 85 d2 test %edx,%edx
6c6: 75 c0 jne 688 <malloc+0x48>
return 0;
6c8: 31 c0 xor %eax,%eax
6ca: eb 1c jmp 6e8 <malloc+0xa8>
6cc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
if(p->s.size == nunits)
6d0: 39 cf cmp %ecx,%edi
6d2: 74 1c je 6f0 <malloc+0xb0>
p->s.size -= nunits;
6d4: 29 f9 sub %edi,%ecx
6d6: 89 48 04 mov %ecx,0x4(%eax)
p += p->s.size;
6d9: 8d 04 c8 lea (%eax,%ecx,8),%eax
p->s.size = nunits;
6dc: 89 78 04 mov %edi,0x4(%eax)
freep = prevp;
6df: 89 15 d4 09 00 00 mov %edx,0x9d4
return (void*)(p + 1);
6e5: 83 c0 08 add $0x8,%eax
}
}
6e8: 8d 65 f4 lea -0xc(%ebp),%esp
6eb: 5b pop %ebx
6ec: 5e pop %esi
6ed: 5f pop %edi
6ee: 5d pop %ebp
6ef: c3 ret
prevp->s.ptr = p->s.ptr;
6f0: 8b 08 mov (%eax),%ecx
6f2: 89 0a mov %ecx,(%edx)
6f4: eb e9 jmp 6df <malloc+0x9f>
base.s.ptr = freep = prevp = &base;
6f6: c7 05 d4 09 00 00 d8 movl $0x9d8,0x9d4
6fd: 09 00 00
700: c7 05 d8 09 00 00 d8 movl $0x9d8,0x9d8
707: 09 00 00
base.s.size = 0;
70a: b8 d8 09 00 00 mov $0x9d8,%eax
70f: c7 05 dc 09 00 00 00 movl $0x0,0x9dc
716: 00 00 00
719: e9 4e ff ff ff jmp 66c <malloc+0x2c>
|
/**
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0.
*/
#include <aws/chime/model/CreateMediaCapturePipelineRequest.h>
#include <aws/core/utils/json/JsonSerializer.h>
#include <utility>
using namespace Aws::Chime::Model;
using namespace Aws::Utils::Json;
using namespace Aws::Utils;
CreateMediaCapturePipelineRequest::CreateMediaCapturePipelineRequest() :
m_sourceType(MediaPipelineSourceType::NOT_SET),
m_sourceTypeHasBeenSet(false),
m_sourceArnHasBeenSet(false),
m_sinkType(MediaPipelineSinkType::NOT_SET),
m_sinkTypeHasBeenSet(false),
m_sinkArnHasBeenSet(false),
m_clientRequestToken(Aws::Utils::UUID::RandomUUID()),
m_clientRequestTokenHasBeenSet(true),
m_chimeSdkMeetingConfigurationHasBeenSet(false)
{
}
Aws::String CreateMediaCapturePipelineRequest::SerializePayload() const
{
JsonValue payload;
if(m_sourceTypeHasBeenSet)
{
payload.WithString("SourceType", MediaPipelineSourceTypeMapper::GetNameForMediaPipelineSourceType(m_sourceType));
}
if(m_sourceArnHasBeenSet)
{
payload.WithString("SourceArn", m_sourceArn);
}
if(m_sinkTypeHasBeenSet)
{
payload.WithString("SinkType", MediaPipelineSinkTypeMapper::GetNameForMediaPipelineSinkType(m_sinkType));
}
if(m_sinkArnHasBeenSet)
{
payload.WithString("SinkArn", m_sinkArn);
}
if(m_clientRequestTokenHasBeenSet)
{
payload.WithString("ClientRequestToken", m_clientRequestToken);
}
if(m_chimeSdkMeetingConfigurationHasBeenSet)
{
payload.WithObject("ChimeSdkMeetingConfiguration", m_chimeSdkMeetingConfiguration.Jsonize());
}
return payload.View().WriteReadable();
}
|
;-----------------------------------------------------------------------------;
; Author: Stephen Fewer (stephen_fewer[at]harmonysecurity[dot]com)
; Compatible: Windows 7, 2003
; Architecture: x64
;-----------------------------------------------------------------------------;
[BITS 64]
exitfunk:
mov ebx, 0x0A2A1DE0 ; The EXITFUNK as specified by user...
mov r10d, 0x9DBD95A6 ; hash( "kernel32.dll", "GetVersion" )
call rbp ; GetVersion(); (AL will = major version and AH will = minor version)
add rsp, 40 ; cleanup the default param space on stack
cmp al, byte 6 ; If we are not running on Windows Vista, 2008 or 7
jl short goodbye ; Then just call the exit function...
cmp bl, 0xE0 ; If we are trying a call to kernel32.dll!ExitThread on Windows Vista, 2008 or 7...
jne short goodbye ;
mov ebx, 0x6F721347 ; Then we substitute the EXITFUNK to that of ntdll.dll!RtlExitUserThread
goodbye: ; We now perform the actual call to the exit function
push byte 0 ;
pop rcx ; set the exit function parameter
mov r10d, ebx ; place the correct EXITFUNK into r10d
call rbp ; call EXITFUNK( 0 ); |
class Solution {
public:
bool canPlaceFlowers(vector<int>& flowerbed, int n) {
int i = 0, j = 0;
while (i < flowerbed.size()) {
while (i < flowerbed.size() && flowerbed[i] == 1) {
++i;
}
j = i;
while (j < flowerbed.size() && flowerbed[j] == 0) {
++j;
}
if ((j-i) % 2 == 0) {
if (i == 0 || j == flowerbed.size()) {
n -= (j-i) / 2;
} else {
n -= (j-i) / 2 - 1;
}
} else {
if (i == 0 && j == flowerbed.size()) {
n -= (j-i) / 2 + 1;
} else {
n -= (j-i) / 2;
}
}
if (n <= 0)
break;
i = j;
}
return n <= 0;
}
};
|
;
;
; Support char table (pseudo graph symbols) for the Mattel Aquarius
; Version for the 2x3 graphics symbols
; Sequence: blank, top-left, top-right, top-half, medium-left, top-left + medium-left, etc..
;
; $Id: textpixl6.asm,v 1.1 2006/12/28 18:08:36 stefano Exp $
;
;
XLIB textpixl
.textpixl
defb $C0, $C1, $C8, $C9, $C2, $C3, $CA, $CB
defb $D0, $D1, $D8, $D9, $D2, $D3, $DA, $DB
defb $C4, $C5, $CC, $CD, $C6, $C7, $CE, $CF
defb $D4, $D5, $DC, $DD, $D6, $D7, $DE, $DF
defb $E0, $E1, $E8, $E9, $E2, $E3, $EA, $EB
defb $F0, $F1, $F8, $F9, $F2, $F3, $FA, $FB
defb $E4, $E5, $EC, $ED, $E6, $E7, $EE, $EF
defb $F4, $F5, $FC, $FD, $F6, $F7, $FE, $FF
|
.global s_prepare_buffers
s_prepare_buffers:
push %r10
push %r13
push %r8
push %r9
push %rbp
push %rcx
push %rdi
push %rsi
lea addresses_D_ht+0x1dbbf, %r8
clflush (%r8)
cmp %r10, %r10
mov $0x6162636465666768, %r13
movq %r13, %xmm4
vmovups %ymm4, (%r8)
cmp $31324, %r9
lea addresses_normal_ht+0xf2f, %rsi
lea addresses_D_ht+0x1023f, %rdi
clflush (%rdi)
nop
nop
nop
sub %r9, %r9
mov $55, %rcx
rep movsb
nop
nop
nop
nop
and $41761, %r9
lea addresses_WT_ht+0x16e5, %r8
nop
nop
add %r13, %r13
mov (%r8), %rcx
and $61656, %r10
lea addresses_WC_ht+0x1bbf, %rcx
nop
nop
xor $7831, %r8
mov (%rcx), %esi
nop
nop
nop
nop
nop
add $3883, %rsi
lea addresses_D_ht+0xc1bf, %r9
nop
nop
nop
add $44103, %r10
mov (%r9), %r8w
nop
nop
nop
nop
nop
cmp $23651, %r10
lea addresses_D_ht+0x17bc6, %r10
nop
nop
nop
nop
nop
xor %r9, %r9
movb $0x61, (%r10)
nop
nop
nop
nop
nop
add %r9, %r9
lea addresses_normal_ht+0x33bf, %rsi
lea addresses_WC_ht+0x19ff, %rdi
nop
nop
and $52850, %rbp
mov $32, %rcx
rep movsl
nop
nop
nop
xor %r8, %r8
lea addresses_A_ht+0xf9db, %rcx
nop
nop
nop
nop
xor %r13, %r13
movl $0x61626364, (%rcx)
nop
xor $19462, %r13
lea addresses_WT_ht+0x1a973, %rsi
lea addresses_WC_ht+0xb3f, %rdi
clflush (%rsi)
nop
nop
nop
xor %r10, %r10
mov $101, %rcx
rep movsw
nop
nop
nop
dec %r9
lea addresses_UC_ht+0x1e707, %rdi
nop
nop
nop
nop
sub %rcx, %rcx
vmovups (%rdi), %ymm4
vextracti128 $1, %ymm4, %xmm4
vpextrq $0, %xmm4, %r10
nop
nop
cmp $10613, %rcx
lea addresses_WC_ht+0x1c3bf, %rsi
lea addresses_normal_ht+0x109bf, %rdi
nop
nop
nop
nop
add %r10, %r10
mov $85, %rcx
rep movsb
nop
nop
nop
nop
nop
sub $34160, %r8
lea addresses_WC_ht+0xfff, %rsi
lea addresses_WT_ht+0x1a33f, %rdi
nop
nop
nop
nop
sub %r10, %r10
mov $30, %rcx
rep movsw
cmp $11268, %rcx
lea addresses_D_ht+0x97bf, %rsi
lea addresses_WT_ht+0x36bf, %rdi
nop
nop
nop
nop
xor $19017, %rbp
mov $65, %rcx
rep movsl
nop
and %rdi, %rdi
lea addresses_normal_ht+0x17e0d, %rsi
lea addresses_normal_ht+0x43bf, %rdi
nop
cmp $50421, %r8
mov $15, %rcx
rep movsb
nop
nop
add %rsi, %rsi
pop %rsi
pop %rdi
pop %rcx
pop %rbp
pop %r9
pop %r8
pop %r13
pop %r10
ret
.global s_faulty_load
s_faulty_load:
push %r10
push %r14
push %r15
push %r9
push %rbp
push %rbx
push %rdx
// Load
lea addresses_normal+0x1947d, %rbx
nop
xor %r14, %r14
movups (%rbx), %xmm6
vpextrq $1, %xmm6, %rdx
sub %r14, %r14
// Store
mov $0x41ebc60000000f4e, %r10
nop
cmp %rbp, %rbp
mov $0x5152535455565758, %r14
movq %r14, %xmm7
movups %xmm7, (%r10)
nop
nop
nop
nop
inc %r10
// Store
mov $0x5ffe9100000001ef, %r10
nop
nop
nop
sub $7659, %r9
mov $0x5152535455565758, %rdx
movq %rdx, %xmm4
movntdq %xmm4, (%r10)
nop
nop
nop
nop
nop
cmp $47594, %r14
// Store
lea addresses_RW+0x1a447, %rbx
nop
nop
nop
dec %r15
mov $0x5152535455565758, %r10
movq %r10, %xmm3
movups %xmm3, (%rbx)
nop
nop
nop
nop
nop
cmp $1682, %r9
// Store
lea addresses_PSE+0x79bf, %r15
nop
nop
nop
nop
add %r9, %r9
movl $0x51525354, (%r15)
nop
nop
cmp %r9, %r9
// Load
lea addresses_A+0x1babf, %r15
and $18666, %rbx
mov (%r15), %r14
nop
nop
nop
add %r14, %r14
// Faulty Load
lea addresses_PSE+0x1b3bf, %r10
nop
nop
nop
nop
dec %rbp
mov (%r10), %dx
lea oracles, %r10
and $0xff, %rdx
shlq $12, %rdx
mov (%r10,%rdx,1), %rdx
pop %rdx
pop %rbx
pop %rbp
pop %r9
pop %r15
pop %r14
pop %r10
ret
/*
<gen_faulty_load>
[REF]
{'src': {'type': 'addresses_PSE', 'same': False, 'size': 1, 'congruent': 0, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'}
{'src': {'type': 'addresses_normal', 'same': False, 'size': 16, 'congruent': 1, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'}
{'dst': {'type': 'addresses_NC', 'same': False, 'size': 16, 'congruent': 0, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'}
{'dst': {'type': 'addresses_NC', 'same': False, 'size': 16, 'congruent': 4, 'NT': True, 'AVXalign': False}, 'OP': 'STOR'}
{'dst': {'type': 'addresses_RW', 'same': False, 'size': 16, 'congruent': 3, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'}
{'dst': {'type': 'addresses_PSE', 'same': False, 'size': 4, 'congruent': 9, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'}
{'src': {'type': 'addresses_A', 'same': False, 'size': 8, 'congruent': 8, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'}
[Faulty Load]
{'src': {'type': 'addresses_PSE', 'same': True, 'size': 2, 'congruent': 0, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'}
<gen_prepare_buffer>
{'dst': {'type': 'addresses_D_ht', 'same': True, 'size': 32, 'congruent': 9, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'}
{'src': {'type': 'addresses_normal_ht', 'congruent': 3, 'same': False}, 'dst': {'type': 'addresses_D_ht', 'congruent': 7, 'same': False}, 'OP': 'REPM'}
{'src': {'type': 'addresses_WT_ht', 'same': False, 'size': 8, 'congruent': 1, 'NT': True, 'AVXalign': False}, 'OP': 'LOAD'}
{'src': {'type': 'addresses_WC_ht', 'same': False, 'size': 4, 'congruent': 10, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'}
{'src': {'type': 'addresses_D_ht', 'same': False, 'size': 2, 'congruent': 6, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'}
{'dst': {'type': 'addresses_D_ht', 'same': False, 'size': 1, 'congruent': 0, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'}
{'src': {'type': 'addresses_normal_ht', 'congruent': 11, 'same': False}, 'dst': {'type': 'addresses_WC_ht', 'congruent': 6, 'same': True}, 'OP': 'REPM'}
{'dst': {'type': 'addresses_A_ht', 'same': False, 'size': 4, 'congruent': 2, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'}
{'src': {'type': 'addresses_WT_ht', 'congruent': 2, 'same': False}, 'dst': {'type': 'addresses_WC_ht', 'congruent': 7, 'same': False}, 'OP': 'REPM'}
{'src': {'type': 'addresses_UC_ht', 'same': False, 'size': 32, 'congruent': 3, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'}
{'src': {'type': 'addresses_WC_ht', 'congruent': 11, 'same': False}, 'dst': {'type': 'addresses_normal_ht', 'congruent': 8, 'same': False}, 'OP': 'REPM'}
{'src': {'type': 'addresses_WC_ht', 'congruent': 6, 'same': False}, 'dst': {'type': 'addresses_WT_ht', 'congruent': 7, 'same': False}, 'OP': 'REPM'}
{'src': {'type': 'addresses_D_ht', 'congruent': 7, 'same': False}, 'dst': {'type': 'addresses_WT_ht', 'congruent': 6, 'same': True}, 'OP': 'REPM'}
{'src': {'type': 'addresses_normal_ht', 'congruent': 0, 'same': False}, 'dst': {'type': 'addresses_normal_ht', 'congruent': 11, 'same': True}, 'OP': 'REPM'}
{'33': 149}
33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33
*/
|
; A109194: Number of returns to the x-axis (i.e., d or u steps hitting the x-axis) in all Grand Motzkin paths of length n. (A Grand Motzkin path of length n is a path in the half-plane x>=0, starting at (0,0), ending at (n,0) and consisting of steps u=(1,1), d=(1,-1) and h=(1,0).).
; Submitted by Simon Strandgaard
; 2,6,22,70,224,700,2174,6702,20572,62920,191932,584220,1775258,5386846,16326734,49435150,149557436,452133880,1366012832,4124825872,12449394278,37558361290,113266431860,341467468420,1029119688014,3100728586290,9340155873574,28128513051622,84693540280384,254960105285292,767395602354158,2309391043916974,6948836033589836,20905850128482760,62888185770783568,189155784065955072,568883061352489574,1710733508341886346,5143995512256731944,15466081047631184824,46496885031860408474,139776289042818055054
mov $1,1
mov $2,$0
mov $3,$0
lpb $2
mov $0,$3
sub $2,1
sub $0,$2
seq $0,187306 ; Alternating sum of Motzkin numbers A001006.
mul $1,3
add $1,$0
lpe
mov $0,$1
mul $0,2
|
[bits 32]
mov eax, [eax-0x10]
add eax, [esi+0x10]
add eax, [0x10]
add eax, [esi+edi*4+0x10]
add eax, [bx+si-0x4877]
|
; A001761: a(n) = (2*n)!/(n+1)!.
; 1,1,4,30,336,5040,95040,2162160,57657600,1764322560,60949324800,2346549004800,99638080819200,4626053752320000,233153109116928000,12677700308232960000,739781100339240960000,46113021921146019840000,3058021453718104473600000,214978908196382744494080000,15969861751731289590988800000,1250004633476421848894668800000,102826468110321310352552755200000,8868782874515213017907675136000000,800318966596252822735988604272640000,75414671852339208296275849248768000000,7407396657496428903767538970656768000000
add $0,1
mov $1,1
mov $2,$0
lpb $0
max $0,3
sub $0,1
add $2,1
mul $1,$2
lpe
mov $0,$1
|
; A007064: Numbers not of form "nearest integer to n*tau", tau=(1+sqrt(5))/2.
; 1,4,7,9,12,14,17,20,22,25,27,30,33,35,38,41,43,46,48,51,54,56,59,62,64,67,69,72,75,77,80,82,85,88,90,93,96,98,101,103,106,109,111,114,117,119,122,124,127,130,132,135,137,140,143,145,148,151,153,156,158,161,164,166,169,171,174,177,179,182,185,187,190,192,195,198,200,203,206,208,211,213,216,219,221,224,226,229,232,234,237,240,242,245,247,250,253,255,258,260
seq $0,184517 ; Upper s-Wythoff sequence, where s=4n-2. Complement of A184516.
div $0,2
|
/*
* This file is a part of the open source stm32plus library.
* Copyright (c) 2011,2012 Andy Brown <www.andybrown.me.uk>
* Please see website for licensing terms.
*/
.global BulbPixels
.global BulbPixelsSize
.global AudioPixels
.global AudioPixelsSize
.global FlagPixels
.global FlagPixelsSize
.global DocPixels
.global DocPixelsSize
.global GlobePixels
.global GlobePixelsSize
BulbPixels:
.incbin "lzg/st7783/bulb.st7783.64.lzg"
BulbPixelsSize=.-BulbPixels
AudioPixels:
.incbin "lzg/st7783/audio.st7783.64.lzg"
AudioPixelsSize=.-AudioPixels
FlagPixels:
.incbin "lzg/st7783/flag.st7783.64.lzg"
FlagPixelsSize=.-FlagPixels
DocPixels:
.incbin "lzg/st7783/doc.st7783.64.lzg"
DocPixelsSize=.-DocPixels
GlobePixels:
.incbin "lzg/st7783/globe.st7783.64.lzg"
GlobePixelsSize=.-GlobePixels
|
; A283394: a(n) = 3*n*(3*n + 7)/2 + 4.
; 4,19,43,76,118,169,229,298,376,463,559,664,778,901,1033,1174,1324,1483,1651,1828,2014,2209,2413,2626,2848,3079,3319,3568,3826,4093,4369,4654,4948,5251,5563,5884,6214,6553,6901,7258,7624,7999,8383,8776,9178,9589,10009,10438,10876,11323,11779,12244,12718,13201,13693,14194,14704,15223,15751,16288,16834,17389,17953,18526,19108,19699,20299,20908,21526,22153,22789,23434,24088,24751,25423,26104,26794,27493,28201,28918,29644,30379,31123,31876,32638,33409,34189,34978,35776,36583,37399,38224,39058,39901,40753,41614,42484,43363,44251,45148
mul $0,3
add $0,4
bin $0,2
sub $0,2
|
; A008356: Crystal ball sequence for D_5 lattice.
; 1,41,411,2051,6981,18733,42783,86983,161993,281713,463715,729675,1105805,1623285,2318695,3234447,4419217,5928377,7824427,10177427,13065429,16574909,20801199,25848919,31832409,38876161,47115251,56695771,67775261,80523141,95121143,111763743,130658593,152026953,176104123,203139875,233398885,267161165,304722495,346394855,392506857,443404177,499449987,561025387,628529837,702381589,783018119,870896559,966494129,1070308569,1182858571,1304684211,1436347381,1578432221,1731545551,1896317303,2073400953,2263473953,2467238163,2685420283,2918772285,3168071845,3434122775,3717755455,4019827265,4341223017,4682855387,5045665347,5430622597,5838725997,6271003999,6728515079,7212348169,7723623089,8263490979,8833134731,9433769421,10066642741,10733035431,11434261711,12171669713,12946641913,13760595563,14614983123,15511292693,16451048445,17435811055,18467178135,19546784665,20676303425,21857445427,23091960347,24381636957,25728303557,27133828407,28600120159,30129128289,31722843529,33383298299,35112567139
mov $1,1
lpb $0
mov $2,$0
sub $0,1
seq $2,8355 ; Coordination sequence for D_5 lattice.
add $1,$2
lpe
mov $0,$1
|
.include "header.inc"
.include "snesregs.inc"
.include "misc_macros.inc"
.include "zeropage.inc"
.include "gamepads.inc"
.16BIT
.ramsection "gamepad vars" bank 0 slot RAM_SLOT
; Buffer for reading bytes from controllers. Logic can
; look at those to know the current button status. gamepads.inc
; contains defines that can help masking buttons.
gamepad1_bytes: dsb 4
gamepad2_bytes: dsb 4
; "Button pressed" event bits. When a button goes down, the
; corresponding bit gets set here. Must be cleared manually.
gamepad1_pressed: dsb 4
gamepad2_pressed: dsb 4
; Buffers holding previously read values for edge detection and
; setting the gamepadX_pressed bits.
gamepad1_prev_bytes: dsb 4
gamepad2_prev_bytes: dsb 4
; Those contain the ID bits (cycles 12-16) for each controller;
ctl_id_p1: db
ctl_id_p2: db
.ends
.bank 0
.section "Gamepads" FREE
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Send a latch pulse to the controllers.
;
; Assumes 8-bit accumulator.
sendLatch:
pha
stz JOYWR ; Bit 0 is the latch. Make sure it is initially clear;
lda #1.B ; Prepare to set bit 0
sta JOYWR ; Do it
; TODO : How much delay cycles should be used here?
nop
nop
nop
stz JOYWR ; Clear latch
pla
rts
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Just return after 8 nops
gamepads_delay_8nops:
nop
nop
nop
nop
nop
nop
nop
nop
rts
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Read 1 byte from gamepad 1
;
; Assumptions: AXY 8bit
;
; Arguments:
; X: destination index in gamepad1_bytes
;
readGamepad1byte:
pha
phy
ldy #8.B
@lp:
lda JOYA ; Read data, generate clock pulse
lsr ; Move bit 0 from controller to the carry flag
rol gamepad1_bytes, X ; Rotate the bit into memory
dey
bne @lp
ply
pla
rts
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Read 1 byte from gamepad 2
;
; Assumptions: AXY 8bit
;
; Arguments:
; X: destination index in gamepad2_bytes
;
readGamepad2byte:
pha
phy
ldy #8.B
@lp:
lda JOYB ; Read data, generate clock pulse
lsr ; Move bit 0 from controller to the carry flag
rol gamepad2_bytes, X ; Rotate the bit into memory
dey
bne @lp
ply
pla
rts
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Read 32 bits from gamepad in port 1
;
; Bytes stored in gamepad1_bytes[4]
readGamepad1:
pushall
A8
XY8
; First 16 bits
ldx #0.B
jsr readGamepad1byte
inx
jsr readGamepad1byte
inx
; Check the ID bits, decide if more bits shall be read
jsr extractIdBits1
lda ctl_id_p1
cmp #CTL_ID_NTT_KEYPAD
beq @read_more
; Otherwise, zero extra bytes in array
stz gamepad1_bytes, X
inx
stz gamepad1_bytes, X
bra @done
@read_more:
jsr readGamepad1byte
inx
jsr readGamepad1byte
@done:
popall
rts
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Read 32 bits from gamepad in port 2
;
; Assumes: AXY 8 bit
;
; Bytes stored in gamepad2_bytes[4]
readGamepad2:
pushall
ldx #0.B
jsr readGamepad2byte
inx
jsr readGamepad2byte
inx
jsr extractIdBits2
lda ctl_id_p2
cmp #CTL_ID_NTT_KEYPAD
beq @read_more
; Otherwise, zero extra bytes in array
stz gamepad2_bytes, X
inx
stz gamepad2_bytes, X
bra @done
@read_more:
jsr readGamepad2byte
inx
jsr readGamepad2byte
@done:
popall
rts
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Compare the current state of Gamepad 1 with the previous state and
; update gamepad1_pressed[4] to indicate which buttons were pressed
; since last call.
;
gamepad1_detectEvents:
pushall
A16
XY16
lda gamepad1_bytes ; Get latest button status
tax ; Store a copy in X
eor gamepad1_prev_bytes ; XOR with previous status (clears unchanged bits)
and gamepad1_bytes ; Keep only newly set bits (buttons that are down *now*)
ora gamepad1_pressed ; Flag those as pressed (will need to be cleared by 'consumer')
sta gamepad1_pressed ; Save new 'active' buttons
stx gamepad1_prev_bytes ; Save previous state for next pass
lda gamepad1_bytes+2
tax
eor gamepad1_prev_bytes+2
and gamepad1_bytes+2
ora gamepad1_pressed+2
sta gamepad1_pressed+2
stx gamepad1_prev_bytes+2
popall
rts
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Compare the current state of Gamepad 2 with the previous state and
; update gamepad2_pressed[4] to indicate which buttons were pressed
; since last call.
;
gamepad2_detectEvents:
pushall
A16
XY16
lda gamepad2_bytes
tax
eor gamepad2_prev_bytes
and gamepad2_bytes
ora gamepad2_pressed
sta gamepad2_pressed
stx gamepad2_prev_bytes
lda gamepad2_bytes+2
tax
eor gamepad2_prev_bytes+2
and gamepad2_bytes+2
ora gamepad2_pressed+2
sta gamepad2_pressed+2
stx gamepad2_prev_bytes+2
popall
rts
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Extract the ID bytes from gamepad1_bytes and store them
; in ctl_id_p1.
;
extractIdBits1:
pha
php
A8
lda gamepad1_bytes+1
and #$F
sta ctl_id_p1
plp
pla
rts
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Extract the ID bytes from gamepad2_bytes and store them
; in ctl_id_p2.
;
extractIdBits2:
pha
php
A8
lda gamepad2_bytes+1
and #$F
sta ctl_id_p2
plp
pla
rts
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Read 32 bits from both gamepads
;
; Assumes: AXY 8 bit
;
; Bytes stoed in gamepad1_bytes[4] and gamepad2_bytes[4]
readGamepads:
; First send a latch to both controllers
jsr sendLatch
jsr gamepads_delay_8nops
; The shift in 32 bits from each controller
jsr readGamepad1
jsr readGamepad2
; Compute button events (falling edge)
jsr gamepad1_detectEvents
jsr gamepad2_detectEvents
rts
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Initialize gamepad variables.
;
gamepads_init:
pushall
A16
stz gamepad1_prev_bytes
stz gamepad1_prev_bytes + 2
stz gamepad2_prev_bytes
stz gamepad2_prev_bytes + 2
stz gamepad1_pressed
stz gamepad1_pressed + 2
stz gamepad2_pressed
stz gamepad2_pressed + 2
popall
rts
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; Get last event from port 1
;
; X: Index into gamepad1_pressed
;
; Returns data in A
;
gamepads_p1_getEvents:
lda gamepad1_pressed,X
rts
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; Clear events for controller port 1
;
gamepads_p1_clearEvents:
pha
php
A16
stz gamepad1_pressed
stz gamepad1_pressed + 2
plp
pla
rts
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; Get last event from port 2
;
; X: Index into gamepad2_pressed
;
; Returns data in A
;
gamepads_p2_getEvents:
lda gamepad2_pressed,X
rts
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; Clear events for controller port 2
;
gamepads_p2_clearEvents:
pha
php
A16
stz gamepad2_pressed
stz gamepad2_pressed + 2
plp
pla
rts
.ends
|
; A135136: a(n) = floor(S2(n)/2) mod 2, where S2(n) is the binary weight of n.
; 0,0,0,1,0,1,1,1,0,1,1,1,1,1,1,0,0,1,1,1,1,1,1,0,1,1,1,0,1,0,0,0,0,1,1,1,1,1,1,0,1,1,1,0,1,0,0,0,1,1,1,0,1,0,0,0,1,0,0,0,0,0,0,1,0,1,1,1,1,1,1,0,1,1,1,0,1,0,0,0,1,1,1,0,1,0,0,0,1,0,0,0,0,0,0,1,1,1,1,0,1,0,0,0,1,0,0,0,0,0,0,1,1,0,0,0,0,0,0,1,0,0,0,1,0,1,1,1,0,1,1,1,1,1,1,0,1,1,1,0,1,0,0,0,1,1,1,0,1,0,0,0,1,0,0,0,0,0,0,1,1,1,1,0,1,0,0,0,1,0,0,0,0,0,0,1,1,0,0,0,0,0,0,1,0,0,0,1,0,1,1,1,1,1,1,0,1,0,0,0,1,0,0,0,0,0,0,1,1,0,0,0,0,0,0,1,0,0,0,1,0,1,1,1,1,0,0,0,0,0,0,1,0,0,0,1,0,1,1,1,0,0,0,1,0,1,1,1,0,1
mov $2,$0
mov $4,$0
lpb $2,1
add $4,$2
lpb $4,1
sub $4,$2
div $2,2
lpe
mul $2,2
mov $3,$4
trn $3,1
add $3,1
add $2,$3
mov $5,$3
mul $5,$2
mov $0,$5
sub $2,2
mov $4,2
lpe
mov $1,$0
div $1,3
|
.global s_prepare_buffers
s_prepare_buffers:
push %r11
push %r13
push %r8
push %r9
push %rax
push %rcx
push %rdi
push %rsi
lea addresses_UC_ht+0x1664a, %rsi
lea addresses_UC_ht+0x1de0a, %rdi
nop
nop
nop
sub $42024, %r8
mov $48, %rcx
rep movsb
nop
nop
nop
nop
xor $19540, %r11
lea addresses_UC_ht+0xb14a, %r13
nop
nop
nop
nop
mfence
mov (%r13), %rcx
nop
nop
nop
nop
nop
cmp $21469, %rsi
lea addresses_WC_ht+0x65ca, %rax
nop
nop
nop
nop
nop
xor %r8, %r8
vmovups (%rax), %ymm7
vextracti128 $1, %ymm7, %xmm7
vpextrq $1, %xmm7, %rdi
nop
nop
nop
nop
nop
dec %r11
lea addresses_UC_ht+0x1c9ca, %r13
cmp $55291, %rsi
movl $0x61626364, (%r13)
nop
nop
nop
nop
nop
add %r11, %r11
lea addresses_normal_ht+0x7b72, %rsi
lea addresses_normal_ht+0xa172, %rdi
dec %rax
mov $82, %rcx
rep movsl
nop
and $51956, %rdi
lea addresses_D_ht+0x9e4a, %rdi
nop
nop
dec %rax
mov (%rdi), %r8
dec %rcx
lea addresses_D_ht+0x3616, %rsi
nop
sub %r8, %r8
mov $0x6162636465666768, %rdi
movq %rdi, %xmm6
movups %xmm6, (%rsi)
nop
nop
sub $23592, %rdi
lea addresses_UC_ht+0x686a, %rsi
lea addresses_D_ht+0x1064a, %rdi
clflush (%rsi)
nop
add %r9, %r9
mov $7, %rcx
rep movsl
nop
nop
nop
nop
nop
sub $53202, %rdi
lea addresses_UC_ht+0x2da, %r13
nop
nop
nop
dec %r8
mov $0x6162636465666768, %rsi
movq %rsi, %xmm6
movups %xmm6, (%r13)
nop
nop
nop
nop
and %r8, %r8
lea addresses_WT_ht+0x2bb6, %r13
clflush (%r13)
nop
nop
nop
nop
nop
and $13027, %rax
mov $0x6162636465666768, %rcx
movq %rcx, %xmm0
and $0xffffffffffffffc0, %r13
movaps %xmm0, (%r13)
nop
nop
dec %rax
lea addresses_WT_ht+0x13b4a, %rsi
lea addresses_UC_ht+0x1ed4a, %rdi
nop
nop
nop
cmp %r9, %r9
mov $109, %rcx
rep movsw
nop
xor $7597, %rdi
lea addresses_UC_ht+0xe24a, %r13
nop
cmp %rcx, %rcx
mov (%r13), %esi
nop
nop
inc %rcx
pop %rsi
pop %rdi
pop %rcx
pop %rax
pop %r9
pop %r8
pop %r13
pop %r11
ret
.global s_faulty_load
s_faulty_load:
push %r10
push %r11
push %r13
push %r14
push %r8
push %rbx
push %rdi
// Store
lea addresses_WC+0x12e4a, %r13
nop
nop
nop
nop
sub %rdi, %rdi
movb $0x51, (%r13)
nop
sub %rbx, %rbx
// Load
lea addresses_A+0x64a, %r10
inc %r8
movups (%r10), %xmm7
vpextrq $1, %xmm7, %r13
cmp %r14, %r14
// Store
mov $0x79bae000000064a, %r10
dec %r11
mov $0x5152535455565758, %rdi
movq %rdi, %xmm6
movups %xmm6, (%r10)
nop
nop
nop
xor $5663, %r11
// Store
mov $0x15f0b50000000b4a, %r8
nop
nop
nop
nop
and $26511, %r13
mov $0x5152535455565758, %r11
movq %r11, %xmm4
movaps %xmm4, (%r8)
nop
cmp $21184, %r13
// Store
lea addresses_WC+0x1186d, %r10
nop
nop
nop
nop
nop
cmp %r14, %r14
mov $0x5152535455565758, %rbx
movq %rbx, (%r10)
nop
xor $63306, %r13
// Faulty Load
lea addresses_US+0x1ee4a, %rdi
clflush (%rdi)
nop
and $65313, %rbx
mov (%rdi), %r11
lea oracles, %rbx
and $0xff, %r11
shlq $12, %r11
mov (%rbx,%r11,1), %r11
pop %rdi
pop %rbx
pop %r8
pop %r14
pop %r13
pop %r11
pop %r10
ret
/*
<gen_faulty_load>
[REF]
{'OP': 'LOAD', 'src': {'same': True, 'NT': False, 'AVXalign': False, 'size': 4, 'type': 'addresses_US', 'congruent': 0}}
{'dst': {'same': False, 'NT': False, 'AVXalign': False, 'size': 1, 'type': 'addresses_WC', 'congruent': 10}, 'OP': 'STOR'}
{'OP': 'LOAD', 'src': {'same': False, 'NT': False, 'AVXalign': False, 'size': 16, 'type': 'addresses_A', 'congruent': 11}}
{'dst': {'same': False, 'NT': False, 'AVXalign': False, 'size': 16, 'type': 'addresses_NC', 'congruent': 11}, 'OP': 'STOR'}
{'dst': {'same': False, 'NT': False, 'AVXalign': True, 'size': 16, 'type': 'addresses_NC', 'congruent': 8}, 'OP': 'STOR'}
{'dst': {'same': False, 'NT': False, 'AVXalign': False, 'size': 8, 'type': 'addresses_WC', 'congruent': 0}, 'OP': 'STOR'}
[Faulty Load]
{'OP': 'LOAD', 'src': {'same': True, 'NT': False, 'AVXalign': False, 'size': 8, 'type': 'addresses_US', 'congruent': 0}}
<gen_prepare_buffer>
{'dst': {'same': False, 'congruent': 4, 'type': 'addresses_UC_ht'}, 'OP': 'REPM', 'src': {'same': False, 'congruent': 11, 'type': 'addresses_UC_ht'}}
{'OP': 'LOAD', 'src': {'same': True, 'NT': False, 'AVXalign': False, 'size': 8, 'type': 'addresses_UC_ht', 'congruent': 2}}
{'OP': 'LOAD', 'src': {'same': False, 'NT': False, 'AVXalign': False, 'size': 32, 'type': 'addresses_WC_ht', 'congruent': 7}}
{'dst': {'same': False, 'NT': False, 'AVXalign': True, 'size': 4, 'type': 'addresses_UC_ht', 'congruent': 6}, 'OP': 'STOR'}
{'dst': {'same': False, 'congruent': 2, 'type': 'addresses_normal_ht'}, 'OP': 'REPM', 'src': {'same': False, 'congruent': 2, 'type': 'addresses_normal_ht'}}
{'OP': 'LOAD', 'src': {'same': False, 'NT': False, 'AVXalign': False, 'size': 8, 'type': 'addresses_D_ht', 'congruent': 7}}
{'dst': {'same': False, 'NT': False, 'AVXalign': False, 'size': 16, 'type': 'addresses_D_ht', 'congruent': 2}, 'OP': 'STOR'}
{'dst': {'same': False, 'congruent': 11, 'type': 'addresses_D_ht'}, 'OP': 'REPM', 'src': {'same': False, 'congruent': 2, 'type': 'addresses_UC_ht'}}
{'dst': {'same': False, 'NT': False, 'AVXalign': False, 'size': 16, 'type': 'addresses_UC_ht', 'congruent': 4}, 'OP': 'STOR'}
{'dst': {'same': True, 'NT': False, 'AVXalign': True, 'size': 16, 'type': 'addresses_WT_ht', 'congruent': 0}, 'OP': 'STOR'}
{'dst': {'same': False, 'congruent': 8, 'type': 'addresses_UC_ht'}, 'OP': 'REPM', 'src': {'same': True, 'congruent': 5, 'type': 'addresses_WT_ht'}}
{'OP': 'LOAD', 'src': {'same': False, 'NT': False, 'AVXalign': False, 'size': 4, 'type': 'addresses_UC_ht', 'congruent': 9}}
{'51': 203, '00': 2}
00 00 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51
*/
|
// math.cpp
// math functions
// 08/20/05 (mv)
#include <windows.h>
#include "libct.h"
BEGIN_EXTERN_C
static int lastrand;
int _fltused = 0;
int abs(int n)
{
return (n>0)?n:-n;
}
void srand(unsigned int seed)
{
lastrand = seed;
}
int rand()
{
return (((lastrand = lastrand * 214013L + 2531011L) >> 16) & 0x7FFF);
}
__declspec(naked) void _CIacos()
{
__asm
{
fld st(0)
fld st(0)
fmul
fld1
fsubr
fsqrt
fxch
fpatan
ret
}
}
__declspec(naked) void _ftol2()
{
__asm
{
push ebp
mov ebp,esp
sub esp,20h
and esp,0FFFFFFF0h
fld st(0)
fst dword ptr [esp+18h]
fistp qword ptr [esp+10h]
fild qword ptr [esp+10h]
mov edx,dword ptr [esp+18h]
mov eax,dword ptr [esp+10h]
test eax,eax
je integer_QnaN_or_zero
arg_is_not_integer_QnaN:
fsubp st(1),st
test edx,edx
jns positive
fstp dword ptr [esp]
mov ecx,dword ptr [esp]
xor ecx,80000000h
add ecx,7FFFFFFFh
adc eax,0
mov edx,dword ptr [esp+14h]
adc edx,0
jmp localexit
positive:
fstp dword ptr [esp]
mov ecx,dword ptr [esp]
add ecx,7FFFFFFFh
sbb eax,0
mov edx,dword ptr [esp+14h]
sbb edx,0
jmp localexit
integer_QnaN_or_zero:
mov edx,dword ptr [esp+14h]
test edx,7FFFFFFFh
jne arg_is_not_integer_QnaN
fstp dword ptr [esp+18h]
fstp dword ptr [esp+18h]
localexit:
leave
ret
}
}
END_EXTERN_C |
; A000392: Stirling numbers of second kind S(n,3).
; 0,0,0,1,6,25,90,301,966,3025,9330,28501,86526,261625,788970,2375101,7141686,21457825,64439010,193448101,580606446,1742343625,5228079450,15686335501,47063200806,141197991025,423610750290,1270865805301,3812664524766,11438127792025,34314651811530,102944492305501,308834550658326,926505799458625,2779521693343170,8338573669964101
lpb $0,1
sub $0,1
mul $1,2
add $2,$3
trn $2,3
add $1,$2
mov $3,$2
add $4,$2
mov $2,$4
add $3,$4
mov $4,2
lpe
|
.global s_prepare_buffers
s_prepare_buffers:
push %r10
push %r12
push %rax
push %rbp
push %rcx
push %rdi
push %rsi
lea addresses_UC_ht+0x1c0e0, %rax
nop
nop
nop
and $14998, %rsi
mov $0x6162636465666768, %r10
movq %r10, %xmm6
and $0xffffffffffffffc0, %rax
vmovntdq %ymm6, (%rax)
nop
nop
nop
nop
nop
sub %rax, %rax
lea addresses_WT_ht+0x8ee0, %rsi
lea addresses_WT_ht+0x5a0c, %rdi
nop
nop
add $38512, %rbp
mov $111, %rcx
rep movsw
nop
nop
nop
add $65088, %rbp
lea addresses_A_ht+0xc0be, %rbp
nop
nop
add %r10, %r10
movb (%rbp), %al
nop
nop
nop
nop
and $34647, %rsi
lea addresses_WT_ht+0x1b8d8, %rdi
nop
nop
nop
add %rbp, %rbp
mov (%rdi), %rcx
nop
nop
nop
add %rcx, %rcx
lea addresses_D_ht+0xb56, %rcx
nop
nop
dec %r12
movb (%rcx), %al
nop
xor $7315, %rdi
lea addresses_D_ht+0x7820, %rax
nop
nop
nop
nop
nop
and %r12, %r12
movups (%rax), %xmm0
vpextrq $1, %xmm0, %rcx
nop
nop
nop
xor $33283, %rbp
pop %rsi
pop %rdi
pop %rcx
pop %rbp
pop %rax
pop %r12
pop %r10
ret
.global s_faulty_load
s_faulty_load:
push %r10
push %r12
push %r15
push %rax
push %rbx
push %rdx
push %rsi
// Store
lea addresses_RW+0x1fdd8, %r12
nop
and $36987, %rax
movl $0x51525354, (%r12)
nop
nop
nop
nop
add %r12, %r12
// Store
lea addresses_normal+0x19880, %rbx
nop
nop
nop
xor %rsi, %rsi
movb $0x51, (%rbx)
nop
nop
nop
nop
sub %rax, %rax
// Faulty Load
lea addresses_US+0xcce0, %r12
dec %rax
movb (%r12), %bl
lea oracles, %r15
and $0xff, %rbx
shlq $12, %rbx
mov (%r15,%rbx,1), %rbx
pop %rsi
pop %rdx
pop %rbx
pop %rax
pop %r15
pop %r12
pop %r10
ret
/*
<gen_faulty_load>
[REF]
{'OP': 'LOAD', 'src': {'type': 'addresses_US', 'size': 16, 'AVXalign': False, 'NT': False, 'congruent': 0, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_RW', 'size': 4, 'AVXalign': False, 'NT': False, 'congruent': 2, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_normal', 'size': 1, 'AVXalign': False, 'NT': False, 'congruent': 5, 'same': False}}
[Faulty Load]
{'OP': 'LOAD', 'src': {'type': 'addresses_US', 'size': 1, 'AVXalign': False, 'NT': False, 'congruent': 0, 'same': True}}
<gen_prepare_buffer>
{'OP': 'STOR', 'dst': {'type': 'addresses_UC_ht', 'size': 32, 'AVXalign': False, 'NT': True, 'congruent': 6, 'same': False}}
{'OP': 'REPM', 'src': {'type': 'addresses_WT_ht', 'congruent': 9, 'same': False}, 'dst': {'type': 'addresses_WT_ht', 'congruent': 2, 'same': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_A_ht', 'size': 1, 'AVXalign': False, 'NT': False, 'congruent': 1, 'same': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_WT_ht', 'size': 8, 'AVXalign': False, 'NT': False, 'congruent': 3, 'same': True}}
{'OP': 'LOAD', 'src': {'type': 'addresses_D_ht', 'size': 1, 'AVXalign': False, 'NT': False, 'congruent': 0, 'same': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_D_ht', 'size': 16, 'AVXalign': False, 'NT': False, 'congruent': 6, 'same': False}}
{'00': 18741}
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
*/
|
; A141023: a(n) = 2^n - (3-(-1)^n)/2.
; 0,0,3,6,15,30,63,126,255,510,1023,2046,4095,8190,16383,32766,65535,131070,262143,524286,1048575,2097150,4194303,8388606,16777215,33554430,67108863,134217726,268435455,536870910,1073741823,2147483646,4294967295,8589934590,17179869183,34359738366,68719476735,137438953470,274877906943,549755813886,1099511627775,2199023255550,4398046511103,8796093022206,17592186044415,35184372088830,70368744177663,140737488355326,281474976710655,562949953421310,1125899906842623,2251799813685246,4503599627370495
mov $1,2
pow $1,$0
div $1,3
mul $1,3
mov $0,$1
|
/** @file
A brief file description
@section license License
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
#include "EsiGunzip.h"
#include "gzip.h"
#include <ctype.h>
#include <stdint.h>
using std::string;
using namespace EsiLib;
EsiGunzip::EsiGunzip(const char *debug_tag, ComponentBase::Debug debug_func, ComponentBase::Error error_func)
: ComponentBase(debug_tag, debug_func, error_func), _downstream_length(0), _total_data_length(0)
{
_init = false;
_success = true;
}
bool
EsiGunzip::stream_finish()
{
if (_init) {
if (inflateEnd(&_zstrm) != Z_OK) {
_errorLog("[%s] inflateEnd failed!", __FUNCTION__);
_success = false;
}
_init = false;
}
return _success;
}
bool
EsiGunzip::stream_decode(const char *data, int data_len, std::string &udata)
{
BufferList buf_list;
if (!_init) {
_zstrm.zalloc = Z_NULL;
_zstrm.zfree = Z_NULL;
_zstrm.opaque = Z_NULL;
_zstrm.next_in = 0;
_zstrm.avail_in = 0;
if (inflateInit2(&_zstrm, MAX_WBITS + 16) != Z_OK) {
_errorLog("[%s] inflateInit2 failed!", __FUNCTION__);
_success = false;
return false;
}
_init = true;
}
if (data && (data_len > 0)) {
_zstrm.next_in = reinterpret_cast<Bytef *>(const_cast<char *>(data));
_zstrm.avail_in = data_len;
char raw_buf[BUF_SIZE];
int inflate_result;
int32_t unzipped_data_size = 0;
int32_t curr_buf_size;
do {
_zstrm.next_out = reinterpret_cast<Bytef *>(raw_buf);
_zstrm.avail_out = BUF_SIZE;
inflate_result = inflate(&_zstrm, Z_SYNC_FLUSH);
curr_buf_size = -1;
if ((inflate_result == Z_OK) || (inflate_result == Z_BUF_ERROR)) {
curr_buf_size = BUF_SIZE - _zstrm.avail_out;
} else if (inflate_result == Z_STREAM_END) {
curr_buf_size = BUF_SIZE - _zstrm.avail_out;
}
if (curr_buf_size > BUF_SIZE) {
_errorLog("[%s] buf too large", __FUNCTION__);
break;
}
if (curr_buf_size < 1) {
_errorLog("[%s] buf below zero", __FUNCTION__);
break;
}
unzipped_data_size += curr_buf_size;
// push empty object onto list and add data to in-list object to
// avoid data copy for temporary
buf_list.push_back(string());
string &curr_buf = buf_list.back();
curr_buf.assign(raw_buf, curr_buf_size);
if (inflate_result == Z_STREAM_END) {
break;
}
} while (_zstrm.avail_in > 0);
_total_data_length += data_len;
}
for (BufferList::iterator iter = buf_list.begin(); iter != buf_list.end(); ++iter) {
udata.append(iter->data(), iter->size());
}
return true;
}
EsiGunzip::~EsiGunzip()
{
_downstream_length = 0;
_total_data_length = 0;
_init = false;
_success = true;
}
|
; This small assembly program is made to ensure that the jump
; behavior is similar between the rtl core and the simulator.
slp
slp
slp
debug
debug
label start
debug
debug
slp
quit
|
; A248619: a(n) = (n*(n+1))^4.
; 0,16,1296,20736,160000,810000,3111696,9834496,26873856,65610000,146410000,303595776,592240896,1097199376,1944810000,3317760000,5473632256,8767700496,13680577296,20851360000,31116960000,45558341136,65554433296,92844527616,129600000000,178506250000,242855782416,326653399296,434734510336,572897610000,748052010000,968381956096,1243528298496,1584788925456,2005339210000,2520473760000,3147870802176,3907880570896,4823839112976,5922408960000,7233948160000,8792909200656,10638269396496,12813994352896,15369536160000,18360368010000,21848556971536,25903376695296,30601961865216,36030006250000,42282506250000,49464551874816,57692167127296,67093201809936,77808276810000,89991784960000,103812949610496,119456943092496,137126067287056,157040998560000,179442099360000,204590798818576,232771044730896,264290829336576,299483791360000,338710896810000,382362201079056,430858694922496,484654236938496,544237575210000,610134460810000,682909855911936,763170239287296,851566012012816,948794006250000,1055600100000000,1172781940777216,1301191781185296,1441739429419536,1595395317760000,1763193692160000,1946235926074896,2145693961716496,2362813881958656,2598919616160000,2855416783210000,3133796675144976,3435640384720896,3762623080370176,4116518432010000,4499203191210000,4912661929267456,5358991936778496,5840408288334096,6359249076010000,6917980815360000,7519204027662336,8165659002209296,8860231742470416,9605960100000000
mov $1,$0
pow $1,2
add $0,$1
pow $0,4
|
.plugin "nl.micheldebree.kickass.ViceWrite"
* = $0810
.modify ViceWrite() {
// notice the program counter inside the modifier
// aswell as outside. this is a must!
* = $0810
jsr $ff81
loop:
inc $d020
jmp loop
} |
.MODEL TINY
.CODE
ORG 100H
BEGIN:
MOV AX,10H
MOV BX,0H
DIV BX
MOV AH,4CH
INT 21H
END BEGIN |
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
std::vector<int> parse_input()
{
std::vector<int> vi;
for (std::string s; std::cin >> s; ) {
std::transform(std::begin(s), std::end(s), std::begin(s),
[](const auto& ch) {
return (ch == 'F' || ch == 'L') ? '0' : '1';
});
vi.push_back(std::stoi(s.substr(0, 7), nullptr, 2) * 8 +
std::stoi(s.substr(7), nullptr, 2));
}
return vi;
}
int main()
{
std::vector<int> vi = parse_input();
std::sort(std::begin(vi), std::end(vi));
auto part1 = vi.back();
auto part2 = 1 + *std::adjacent_find(std::begin(vi), std::end(vi),
[](const auto& a, const auto& b) { return b != a + 1; });
std::cout << "Part 1: " << part1 << '\n';
std::cout << "Part 2: " << part2 << '\n';
}
|
; A002424: Expansion of (1-4*x)^(9/2).
; Submitted by Jamie Morken(s4)
; 1,-18,126,-420,630,-252,-84,-72,-90,-140,-252,-504,-1092,-2520,-6120,-15504,-40698,-110124,-305900,-869400,-2521260,-7443720,-22331160,-67964400,-209556900,-653817528,-2062039896,-6567978928,-21111360840,-68429928240,-223537765584,-735511357728,-2436381372474,-8121271241580,-27230144751180,-91804488018264,-311115209395228,-1059473415778344,-3624514317136440,-12453459448622640,-42964435097748108,-148803653265371496,-517269842303434248,-1804429682453840400,-6315503888588441400
mov $1,1
mov $3,$0
mov $0,22
lpb $3
sub $0,4
mul $1,$0
sub $2,1
div $1,$2
sub $3,1
lpe
mov $0,$1
|
; A085431: a(n) = (2^(n-1) + prime(n+1)-prime(n))/2.
; 1,2,3,6,9,18,33,66,131,257,515,1026,2049,4098,8195,16387,32769,65539,131074,262145,524291,1048578,2097155,4194308,8388610,16777217,33554434,67108865,134217730,268435463,536870914,1073741827,2147483649,4294967301,8589934593,17179869187,34359738371,68719476738,137438953475,274877906947,549755813889,1099511627781,2199023255553,4398046511106,8796093022209,17592186044422,35184372088838,70368744177666,140737488355329,281474976710658,562949953421315,1125899906842625,2251799813685253,4503599627370499,9007199254740995,18014398509481987,36028797018963969,72057594037927939,144115188075855874,288230376151711745,576460752303423493,1152921504606846983,2305843009213693954,4611686018427387905,9223372036854775810,18446744073709551623,36893488147419103235,73786976294838206469,147573952589676412929,295147905179352825858,590295810358705651715,1180591620717411303428,2361183241434822606851,4722366482869645213699,9444732965739290427394,18889465931478580854787,37778931862957161709572,75557863725914323419138,151115727451828646838276,302231454903657293676549,604462909807314587353089,1208925819614629174706181,2417851639229258349412353,4835703278458516698824707,9671406556917033397649410,19342813113834066795298819,38685626227668133590597636,77371252455336267181195266,154742504910672534362390529,309485009821345068724781058,618970019642690137449562118,1237940039285380274899124228,2475880078570760549798248450,4951760157141521099596496900,9903520314283042199192993794,19807040628566084398385987587,39614081257132168796771975174,79228162514264337593543950337,158456325028528675187087900681,316912650057057350374175801347
mov $1,2
pow $1,$0
seq $0,46933 ; Number of composites between successive primes.
add $1,$0
div $1,2
add $1,1
mov $0,$1
|
/*
* Copyright 2013 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#include "include/core/SkFont.h"
#include "include/core/SkFontMgr.h"
#include "include/core/SkPaint.h"
#include "include/core/SkStream.h"
#include "include/core/SkTypeface.h"
#include "src/core/SkAdvancedTypefaceMetrics.h"
#include "src/core/SkScalerContext.h"
#include "tests/Test.h"
#include "tools/flags/CommandLineFlags.h"
#include <initializer_list>
#include <limits>
#include <vector>
static void test_font(skiatest::Reporter* reporter) {
SkFont font(nullptr, 24);
//REPORTER_ASSERT(reporter, SkTypeface::GetDefaultTypeface() == font.getTypeface());
REPORTER_ASSERT(reporter, 24 == font.getSize());
REPORTER_ASSERT(reporter, 1 == font.getScaleX());
REPORTER_ASSERT(reporter, 0 == font.getSkewX());
uint16_t glyphs[5];
sk_bzero(glyphs, sizeof(glyphs));
// Check that no glyphs are copied with insufficient storage.
int count = font.textToGlyphs("Hello", 5, SkTextEncoding::kUTF8, glyphs, 2);
REPORTER_ASSERT(reporter, 5 == count);
for (const auto glyph : glyphs) { REPORTER_ASSERT(reporter, glyph == 0); }
SkAssertResult(font.textToGlyphs("Hello", 5, SkTextEncoding::kUTF8, glyphs,
SK_ARRAY_COUNT(glyphs)) == count);
for (int i = 0; i < count; ++i) {
REPORTER_ASSERT(reporter, 0 != glyphs[i]);
}
REPORTER_ASSERT(reporter, glyphs[0] != glyphs[1]); // 'h' != 'e'
REPORTER_ASSERT(reporter, glyphs[2] == glyphs[3]); // 'l' == 'l'
const SkFont newFont(font.makeWithSize(36));
REPORTER_ASSERT(reporter, font.getTypefaceOrDefault() == newFont.getTypefaceOrDefault());
REPORTER_ASSERT(reporter, 36 == newFont.getSize()); // double check we haven't changed
REPORTER_ASSERT(reporter, 24 == font.getSize()); // double check we haven't changed
}
/*
* If the font backend is going to "alias" some font names to other fonts
* (e.g. sans -> Arial) then we want to at least get the same typeface back
* if we request the alias name multiple times.
*/
static void test_alias_names(skiatest::Reporter* reporter) {
const char* inNames[] = {
"sans", "sans-serif", "serif", "monospace", "times", "helvetica"
};
for (size_t i = 0; i < SK_ARRAY_COUNT(inNames); ++i) {
sk_sp<SkTypeface> first(SkTypeface::MakeFromName(inNames[i], SkFontStyle()));
if (nullptr == first.get()) {
continue;
}
for (int j = 0; j < 10; ++j) {
sk_sp<SkTypeface> face(SkTypeface::MakeFromName(inNames[i], SkFontStyle()));
#if 0
SkString name;
face->getFamilyName(&name);
printf("request %s, received %s, first id %x received %x\n",
inNames[i], name.c_str(), first->uniqueID(), face->uniqueID());
#endif
REPORTER_ASSERT(reporter, first->uniqueID() == face->uniqueID());
}
}
}
static void test_fontiter(skiatest::Reporter* reporter, bool verbose) {
sk_sp<SkFontMgr> fm(SkFontMgr::RefDefault());
int count = fm->countFamilies();
for (int i = 0; i < count; ++i) {
SkString fname;
fm->getFamilyName(i, &fname);
sk_sp<SkFontStyleSet> fnset(fm->matchFamily(fname.c_str()));
sk_sp<SkFontStyleSet> set(fm->createStyleSet(i));
REPORTER_ASSERT(reporter, fnset->count() == set->count());
if (verbose) {
SkDebugf("[%2d] %s\n", i, fname.c_str());
}
for (int j = 0; j < set->count(); ++j) {
SkString sname;
SkFontStyle fs;
set->getStyle(j, &fs, &sname);
// REPORTER_ASSERT(reporter, sname.size() > 0);
sk_sp<SkTypeface> face(set->createTypeface(j));
// REPORTER_ASSERT(reporter, face.get());
if (verbose) {
SkDebugf("\t[%d] %s [%3d %d %d]\n", j, sname.c_str(),
fs.weight(), fs.width(), fs.slant());
}
}
}
}
static void test_match(skiatest::Reporter* reporter) {
sk_sp<SkFontMgr> fm(SkFontMgr::RefDefault());
sk_sp<SkFontStyleSet> styleSet(fm->matchFamily(nullptr));
REPORTER_ASSERT(reporter, styleSet);
}
static void test_matchStyleCSS3(skiatest::Reporter* reporter) {
static const SkFontStyle invalidFontStyle(101, SkFontStyle::kNormal_Width, SkFontStyle::kUpright_Slant);
class TestTypeface : public SkTypeface {
public:
TestTypeface(const SkFontStyle& fontStyle) : SkTypeface(fontStyle, false){}
protected:
std::unique_ptr<SkStreamAsset> onOpenStream(int* ttcIndex) const override { return nullptr; }
sk_sp<SkTypeface> onMakeClone(const SkFontArguments& args) const override {
return sk_ref_sp(this);
}
SkScalerContext* onCreateScalerContext(const SkScalerContextEffects& effects,
const SkDescriptor* desc) const override {
return SkScalerContext::MakeEmptyContext(
sk_ref_sp(const_cast<TestTypeface*>(this)), effects, desc);
}
void onFilterRec(SkScalerContextRec*) const override { }
std::unique_ptr<SkAdvancedTypefaceMetrics> onGetAdvancedMetrics() const override {
return nullptr;
}
void onGetFontDescriptor(SkFontDescriptor*, bool*) const override { }
void onCharsToGlyphs(const SkUnichar* chars, int count, SkGlyphID glyphs[]) const override {
sk_bzero(glyphs, count * sizeof(glyphs[0]));
}
int onCountGlyphs() const override { return 0; }
void getPostScriptGlyphNames(SkString*) const override {}
void getGlyphToUnicodeMap(SkUnichar*) const override {}
int onGetUPEM() const override { return 0; }
class EmptyLocalizedStrings : public SkTypeface::LocalizedStrings {
public:
bool next(SkTypeface::LocalizedString*) override { return false; }
};
void onGetFamilyName(SkString* familyName) const override {
familyName->reset();
}
SkTypeface::LocalizedStrings* onCreateFamilyNameIterator() const override {
return new EmptyLocalizedStrings;
}
int onGetVariationDesignPosition(
SkFontArguments::VariationPosition::Coordinate coordinates[],
int coordinateCount) const override
{
return 0;
}
int onGetVariationDesignParameters(SkFontParameters::Variation::Axis parameters[],
int parameterCount) const override
{
return -1;
}
int onGetTableTags(SkFontTableTag tags[]) const override { return 0; }
size_t onGetTableData(SkFontTableTag, size_t, size_t, void*) const override {
return 0;
}
};
class TestFontStyleSet : public SkFontStyleSet {
public:
TestFontStyleSet(std::initializer_list<SkFontStyle> styles) : fStyles(styles) {}
int count() override { return static_cast<int>(fStyles.size()); }
void getStyle(int index, SkFontStyle* style, SkString*) override {
if (style) {
*style = fStyles[index];
}
}
SkTypeface* createTypeface(int index) override {
if (index < 0 || this->count() <= index) {
return new TestTypeface(invalidFontStyle);
}
return new TestTypeface(fStyles[index]);
}
SkTypeface* matchStyle(const SkFontStyle& pattern) override {
return this->matchStyleCSS3(pattern);
}
private:
std::vector<SkFontStyle> fStyles;
};
SkFontStyle condensed_normal_100(SkFontStyle::kThin_Weight, SkFontStyle::kCondensed_Width, SkFontStyle::kUpright_Slant);
SkFontStyle condensed_normal_900(SkFontStyle::kBlack_Weight, SkFontStyle::kCondensed_Width, SkFontStyle::kUpright_Slant);
SkFontStyle condensed_italic_100(SkFontStyle::kThin_Weight, SkFontStyle::kCondensed_Width, SkFontStyle::kItalic_Slant);
SkFontStyle condensed_italic_900(SkFontStyle::kBlack_Weight, SkFontStyle::kCondensed_Width, SkFontStyle::kItalic_Slant);
SkFontStyle condensed_obliqu_100(SkFontStyle::kThin_Weight, SkFontStyle::kCondensed_Width, SkFontStyle::kOblique_Slant);
SkFontStyle condensed_obliqu_900(SkFontStyle::kBlack_Weight, SkFontStyle::kCondensed_Width, SkFontStyle::kOblique_Slant);
SkFontStyle expanded_normal_100(SkFontStyle::kThin_Weight, SkFontStyle::kExpanded_Width, SkFontStyle::kUpright_Slant);
SkFontStyle expanded_normal_900(SkFontStyle::kBlack_Weight, SkFontStyle::kExpanded_Width, SkFontStyle::kUpright_Slant);
SkFontStyle expanded_italic_100(SkFontStyle::kThin_Weight, SkFontStyle::kExpanded_Width, SkFontStyle::kItalic_Slant);
SkFontStyle expanded_italic_900(SkFontStyle::kBlack_Weight, SkFontStyle::kExpanded_Width, SkFontStyle::kItalic_Slant);
SkFontStyle expanded_obliqu_100(SkFontStyle::kThin_Weight, SkFontStyle::kExpanded_Width, SkFontStyle::kOblique_Slant);
SkFontStyle expanded_obliqu_900(SkFontStyle::kBlack_Weight, SkFontStyle::kExpanded_Width, SkFontStyle::kOblique_Slant);
SkFontStyle normal_normal_100(SkFontStyle::kThin_Weight, SkFontStyle::kNormal_Width, SkFontStyle::kUpright_Slant);
SkFontStyle normal_normal_300(SkFontStyle::kLight_Weight, SkFontStyle::kNormal_Width, SkFontStyle::kUpright_Slant);
SkFontStyle normal_normal_400(SkFontStyle::kNormal_Weight, SkFontStyle::kNormal_Width, SkFontStyle::kUpright_Slant);
SkFontStyle normal_normal_500(SkFontStyle::kMedium_Weight, SkFontStyle::kNormal_Width, SkFontStyle::kUpright_Slant);
SkFontStyle normal_normal_600(SkFontStyle::kSemiBold_Weight, SkFontStyle::kNormal_Width, SkFontStyle::kUpright_Slant);
SkFontStyle normal_normal_900(SkFontStyle::kBlack_Weight, SkFontStyle::kNormal_Width, SkFontStyle::kUpright_Slant);
struct StyleSetTest {
TestFontStyleSet styleSet;
struct Case {
SkFontStyle pattern;
SkFontStyle expectedResult;
};
std::vector<Case> cases;
} tests[] = {
{
{ normal_normal_500, normal_normal_400 },
{
{ normal_normal_400, normal_normal_400 },
{ normal_normal_500, normal_normal_500 },
},
},
{
{ normal_normal_500, normal_normal_300 },
{
{ normal_normal_300, normal_normal_300 },
{ normal_normal_400, normal_normal_500 },
{ normal_normal_500, normal_normal_500 },
},
},
{
{ condensed_normal_100,condensed_normal_900,condensed_italic_100,condensed_italic_900,
expanded_normal_100, expanded_normal_900, expanded_italic_100, expanded_italic_900 },
{
{ condensed_normal_100, condensed_normal_100 },
{ condensed_normal_900, condensed_normal_900 },
{ condensed_italic_100, condensed_italic_100 },
{ condensed_italic_900, condensed_italic_900 },
{ expanded_normal_100, expanded_normal_100 },
{ expanded_normal_900, expanded_normal_900 },
{ expanded_italic_100, expanded_italic_100 },
{ expanded_italic_900, expanded_italic_900 },
},
},
{
{ condensed_normal_100,condensed_italic_100,expanded_normal_100,expanded_italic_100 },
{
{ condensed_normal_100, condensed_normal_100 },
{ condensed_normal_900, condensed_normal_100 },
{ condensed_italic_100, condensed_italic_100 },
{ condensed_italic_900, condensed_italic_100 },
{ expanded_normal_100, expanded_normal_100 },
{ expanded_normal_900, expanded_normal_100 },
{ expanded_italic_100, expanded_italic_100 },
{ expanded_italic_900, expanded_italic_100 },
},
},
{
{ condensed_normal_900,condensed_italic_900,expanded_normal_900,expanded_italic_900 },
{
{ condensed_normal_100, condensed_normal_900 },
{ condensed_normal_900, condensed_normal_900 },
{ condensed_italic_100, condensed_italic_900 },
{ condensed_italic_900, condensed_italic_900 },
{ expanded_normal_100, expanded_normal_900 },
{ expanded_normal_900, expanded_normal_900 },
{ expanded_italic_100, expanded_italic_900 },
{ expanded_italic_900, expanded_italic_900 },
},
},
{
{ condensed_normal_100,condensed_normal_900,expanded_normal_100,expanded_normal_900 },
{
{ condensed_normal_100, condensed_normal_100 },
{ condensed_normal_900, condensed_normal_900 },
{ condensed_italic_100, condensed_normal_100 },
{ condensed_italic_900, condensed_normal_900 },
{ expanded_normal_100, expanded_normal_100 },
{ expanded_normal_900, expanded_normal_900 },
{ expanded_italic_100, expanded_normal_100 },
{ expanded_italic_900, expanded_normal_900 },
},
},
{
{ condensed_normal_100,expanded_normal_100 },
{
{ condensed_normal_100, condensed_normal_100 },
{ condensed_normal_900, condensed_normal_100 },
{ condensed_italic_100, condensed_normal_100 },
{ condensed_italic_900, condensed_normal_100 },
{ expanded_normal_100, expanded_normal_100 },
{ expanded_normal_900, expanded_normal_100 },
{ expanded_italic_100, expanded_normal_100 },
{ expanded_italic_900, expanded_normal_100 },
},
},
{
{ condensed_normal_900,expanded_normal_900 },
{
{ condensed_normal_100, condensed_normal_900 },
{ condensed_normal_900, condensed_normal_900 },
{ condensed_italic_100, condensed_normal_900 },
{ condensed_italic_900, condensed_normal_900 },
{ expanded_normal_100, expanded_normal_900 },
{ expanded_normal_900, expanded_normal_900 },
{ expanded_italic_100, expanded_normal_900 },
{ expanded_italic_900, expanded_normal_900 },
},
},
{
{ condensed_italic_100,condensed_italic_900,expanded_italic_100,expanded_italic_900 },
{
{ condensed_normal_100, condensed_italic_100 },
{ condensed_normal_900, condensed_italic_900 },
{ condensed_italic_100, condensed_italic_100 },
{ condensed_italic_900, condensed_italic_900 },
{ expanded_normal_100, expanded_italic_100 },
{ expanded_normal_900, expanded_italic_900 },
{ expanded_italic_100, expanded_italic_100 },
{ expanded_italic_900, expanded_italic_900 },
},
},
{
{ condensed_italic_100,expanded_italic_100 },
{
{ condensed_normal_100, condensed_italic_100 },
{ condensed_normal_900, condensed_italic_100 },
{ condensed_italic_100, condensed_italic_100 },
{ condensed_italic_900, condensed_italic_100 },
{ expanded_normal_100, expanded_italic_100 },
{ expanded_normal_900, expanded_italic_100 },
{ expanded_italic_100, expanded_italic_100 },
{ expanded_italic_900, expanded_italic_100 },
},
},
{
{ condensed_italic_900,expanded_italic_900 },
{
{ condensed_normal_100, condensed_italic_900 },
{ condensed_normal_900, condensed_italic_900 },
{ condensed_italic_100, condensed_italic_900 },
{ condensed_italic_900, condensed_italic_900 },
{ expanded_normal_100, expanded_italic_900 },
{ expanded_normal_900, expanded_italic_900 },
{ expanded_italic_100, expanded_italic_900 },
{ expanded_italic_900, expanded_italic_900 },
},
},
{
{ condensed_normal_100,condensed_normal_900,condensed_italic_100,condensed_italic_900 },
{
{ condensed_normal_100, condensed_normal_100 },
{ condensed_normal_900, condensed_normal_900 },
{ condensed_italic_100, condensed_italic_100 },
{ condensed_italic_900, condensed_italic_900 },
{ expanded_normal_100, condensed_normal_100 },
{ expanded_normal_900, condensed_normal_900 },
{ expanded_italic_100, condensed_italic_100 },
{ expanded_italic_900, condensed_italic_900 },
},
},
{
{ condensed_normal_100,condensed_italic_100 },
{
{ condensed_normal_100, condensed_normal_100 },
{ condensed_normal_900, condensed_normal_100 },
{ condensed_italic_100, condensed_italic_100 },
{ condensed_italic_900, condensed_italic_100 },
{ expanded_normal_100, condensed_normal_100 },
{ expanded_normal_900, condensed_normal_100 },
{ expanded_italic_100, condensed_italic_100 },
{ expanded_italic_900, condensed_italic_100 },
},
},
{
{ condensed_normal_900,condensed_italic_900 },
{
{ condensed_normal_100, condensed_normal_900 },
{ condensed_normal_900, condensed_normal_900 },
{ condensed_italic_100, condensed_italic_900 },
{ condensed_italic_900, condensed_italic_900 },
{ expanded_normal_100, condensed_normal_900 },
{ expanded_normal_900, condensed_normal_900 },
{ expanded_italic_100, condensed_italic_900 },
{ expanded_italic_900, condensed_italic_900 },
},
},
{
{ condensed_normal_100,condensed_normal_900 },
{
{ condensed_normal_100, condensed_normal_100 },
{ condensed_normal_900, condensed_normal_900 },
{ condensed_italic_100, condensed_normal_100 },
{ condensed_italic_900, condensed_normal_900 },
{ expanded_normal_100, condensed_normal_100 },
{ expanded_normal_900, condensed_normal_900 },
{ expanded_italic_100, condensed_normal_100 },
{ expanded_italic_900, condensed_normal_900 },
},
},
{
{ condensed_normal_100 },
{
{ condensed_normal_100, condensed_normal_100 },
{ condensed_normal_900, condensed_normal_100 },
{ condensed_italic_100, condensed_normal_100 },
{ condensed_italic_900, condensed_normal_100 },
{ expanded_normal_100, condensed_normal_100 },
{ expanded_normal_900, condensed_normal_100 },
{ expanded_italic_100, condensed_normal_100 },
{ expanded_italic_900, condensed_normal_100 },
},
},
{
{ condensed_normal_900 },
{
{ condensed_normal_100, condensed_normal_900 },
{ condensed_normal_900, condensed_normal_900 },
{ condensed_italic_100, condensed_normal_900 },
{ condensed_italic_900, condensed_normal_900 },
{ expanded_normal_100, condensed_normal_900 },
{ expanded_normal_900, condensed_normal_900 },
{ expanded_italic_100, condensed_normal_900 },
{ expanded_italic_900, condensed_normal_900 },
},
},
{
{ condensed_italic_100,condensed_italic_900 },
{
{ condensed_normal_100, condensed_italic_100 },
{ condensed_normal_900, condensed_italic_900 },
{ condensed_italic_100, condensed_italic_100 },
{ condensed_italic_900, condensed_italic_900 },
{ expanded_normal_100, condensed_italic_100 },
{ expanded_normal_900, condensed_italic_900 },
{ expanded_italic_100, condensed_italic_100 },
{ expanded_italic_900, condensed_italic_900 },
},
},
{
{ condensed_italic_100 },
{
{ condensed_normal_100, condensed_italic_100 },
{ condensed_normal_900, condensed_italic_100 },
{ condensed_italic_100, condensed_italic_100 },
{ condensed_italic_900, condensed_italic_100 },
{ expanded_normal_100, condensed_italic_100 },
{ expanded_normal_900, condensed_italic_100 },
{ expanded_italic_100, condensed_italic_100 },
{ expanded_italic_900, condensed_italic_100 },
},
},
{
{ condensed_italic_900 },
{
{ condensed_normal_100, condensed_italic_900 },
{ condensed_normal_900, condensed_italic_900 },
{ condensed_italic_100, condensed_italic_900 },
{ condensed_italic_900, condensed_italic_900 },
{ expanded_normal_100, condensed_italic_900 },
{ expanded_normal_900, condensed_italic_900 },
{ expanded_italic_100, condensed_italic_900 },
{ expanded_italic_900, condensed_italic_900 },
},
},
{
{ expanded_normal_100,expanded_normal_900,
expanded_italic_100,expanded_italic_900 },
{
{ condensed_normal_100, expanded_normal_100 },
{ condensed_normal_900, expanded_normal_900 },
{ condensed_italic_100, expanded_italic_100 },
{ condensed_italic_900, expanded_italic_900 },
{ condensed_obliqu_100, expanded_italic_100 },
{ condensed_obliqu_900, expanded_italic_900 },
{ expanded_normal_100, expanded_normal_100 },
{ expanded_normal_900, expanded_normal_900 },
{ expanded_italic_100, expanded_italic_100 },
{ expanded_italic_900, expanded_italic_900 },
{ expanded_obliqu_100, expanded_italic_100 },
{ expanded_obliqu_900, expanded_italic_900 },
},
},
{
{ expanded_normal_100,expanded_italic_100 },
{
{ condensed_normal_100, expanded_normal_100 },
{ condensed_normal_900, expanded_normal_100 },
{ condensed_italic_100, expanded_italic_100 },
{ condensed_italic_900, expanded_italic_100 },
{ expanded_normal_100, expanded_normal_100 },
{ expanded_normal_900, expanded_normal_100 },
{ expanded_italic_100, expanded_italic_100 },
{ expanded_italic_900, expanded_italic_100 },
},
},
{
{ expanded_normal_900,expanded_italic_900 },
{
{ condensed_normal_100, expanded_normal_900 },
{ condensed_normal_900, expanded_normal_900 },
{ condensed_italic_100, expanded_italic_900 },
{ condensed_italic_900, expanded_italic_900 },
{ expanded_normal_100, expanded_normal_900 },
{ expanded_normal_900, expanded_normal_900 },
{ expanded_italic_100, expanded_italic_900 },
{ expanded_italic_900, expanded_italic_900 },
},
},
{
{ expanded_normal_100,expanded_normal_900 },
{
{ condensed_normal_100, expanded_normal_100 },
{ condensed_normal_900, expanded_normal_900 },
{ condensed_italic_100, expanded_normal_100 },
{ condensed_italic_900, expanded_normal_900 },
{ expanded_normal_100, expanded_normal_100 },
{ expanded_normal_900, expanded_normal_900 },
{ expanded_italic_100, expanded_normal_100 },
{ expanded_italic_900, expanded_normal_900 },
},
},
{
{ expanded_normal_100 },
{
{ condensed_normal_100, expanded_normal_100 },
{ condensed_normal_900, expanded_normal_100 },
{ condensed_italic_100, expanded_normal_100 },
{ condensed_italic_900, expanded_normal_100 },
{ expanded_normal_100, expanded_normal_100 },
{ expanded_normal_900, expanded_normal_100 },
{ expanded_italic_100, expanded_normal_100 },
{ expanded_italic_900, expanded_normal_100 },
},
},
{
{ expanded_normal_900 },
{
{ condensed_normal_100, expanded_normal_900 },
{ condensed_normal_900, expanded_normal_900 },
{ condensed_italic_100, expanded_normal_900 },
{ condensed_italic_900, expanded_normal_900 },
{ expanded_normal_100, expanded_normal_900 },
{ expanded_normal_900, expanded_normal_900 },
{ expanded_italic_100, expanded_normal_900 },
{ expanded_italic_900, expanded_normal_900 },
},
},
{
{ expanded_italic_100,expanded_italic_900 },
{
{ condensed_normal_100, expanded_italic_100 },
{ condensed_normal_900, expanded_italic_900 },
{ condensed_italic_100, expanded_italic_100 },
{ condensed_italic_900, expanded_italic_900 },
{ expanded_normal_100, expanded_italic_100 },
{ expanded_normal_900, expanded_italic_900 },
{ expanded_italic_100, expanded_italic_100 },
{ expanded_italic_900, expanded_italic_900 },
},
},
{
{ expanded_italic_100 },
{
{ condensed_normal_100, expanded_italic_100 },
{ condensed_normal_900, expanded_italic_100 },
{ condensed_italic_100, expanded_italic_100 },
{ condensed_italic_900, expanded_italic_100 },
{ expanded_normal_100, expanded_italic_100 },
{ expanded_normal_900, expanded_italic_100 },
{ expanded_italic_100, expanded_italic_100 },
{ expanded_italic_900, expanded_italic_100 },
},
},
{
{ expanded_italic_900 },
{
{ condensed_normal_100, expanded_italic_900 },
{ condensed_normal_900, expanded_italic_900 },
{ condensed_italic_100, expanded_italic_900 },
{ condensed_italic_900, expanded_italic_900 },
{ expanded_normal_100, expanded_italic_900 },
{ expanded_normal_900, expanded_italic_900 },
{ expanded_italic_100, expanded_italic_900 },
{ expanded_italic_900, expanded_italic_900 },
},
},
{
{ normal_normal_100, normal_normal_900 },
{
{ normal_normal_300, normal_normal_100 },
{ normal_normal_400, normal_normal_100 },
{ normal_normal_500, normal_normal_100 },
{ normal_normal_600, normal_normal_900 },
},
},
{
{ normal_normal_100, normal_normal_400, normal_normal_900 },
{
{ normal_normal_300, normal_normal_100 },
{ normal_normal_400, normal_normal_400 },
{ normal_normal_500, normal_normal_400 },
{ normal_normal_600, normal_normal_900 },
},
},
{
{ normal_normal_100, normal_normal_500, normal_normal_900 },
{
{ normal_normal_300, normal_normal_100 },
{ normal_normal_400, normal_normal_500 },
{ normal_normal_500, normal_normal_500 },
{ normal_normal_600, normal_normal_900 },
},
},
{
{ },
{
{ normal_normal_300, invalidFontStyle },
{ normal_normal_400, invalidFontStyle },
{ normal_normal_500, invalidFontStyle },
{ normal_normal_600, invalidFontStyle },
},
},
{
{ expanded_normal_100,expanded_normal_900,
expanded_italic_100,expanded_italic_900,
expanded_obliqu_100,expanded_obliqu_900, },
{
{ condensed_normal_100, expanded_normal_100 },
{ condensed_normal_900, expanded_normal_900 },
{ condensed_italic_100, expanded_italic_100 },
{ condensed_italic_900, expanded_italic_900 },
{ condensed_obliqu_100, expanded_obliqu_100 },
{ condensed_obliqu_900, expanded_obliqu_900 },
{ expanded_normal_100, expanded_normal_100 },
{ expanded_normal_900, expanded_normal_900 },
{ expanded_italic_100, expanded_italic_100 },
{ expanded_italic_900, expanded_italic_900 },
{ expanded_obliqu_100, expanded_obliqu_100 },
{ expanded_obliqu_900, expanded_obliqu_900 },
},
},
{
{ expanded_normal_100,expanded_normal_900,
expanded_obliqu_100,expanded_obliqu_900, },
{
{ condensed_normal_100, expanded_normal_100 },
{ condensed_normal_900, expanded_normal_900 },
{ condensed_italic_100, expanded_obliqu_100 },
{ condensed_italic_900, expanded_obliqu_900 },
{ condensed_obliqu_100, expanded_obliqu_100 },
{ condensed_obliqu_900, expanded_obliqu_900 },
{ expanded_normal_100, expanded_normal_100 },
{ expanded_normal_900, expanded_normal_900 },
{ expanded_italic_100, expanded_obliqu_100 },
{ expanded_italic_900, expanded_obliqu_900 },
{ expanded_obliqu_100, expanded_obliqu_100 },
{ expanded_obliqu_900, expanded_obliqu_900 },
},
},
{
{ expanded_italic_100,expanded_italic_900,
expanded_obliqu_100,expanded_obliqu_900, },
{
{ condensed_normal_100, expanded_obliqu_100 },
{ condensed_normal_900, expanded_obliqu_900 },
{ condensed_italic_100, expanded_italic_100 },
{ condensed_italic_900, expanded_italic_900 },
{ condensed_obliqu_100, expanded_obliqu_100 },
{ condensed_obliqu_900, expanded_obliqu_900 },
{ expanded_normal_100, expanded_obliqu_100 },
{ expanded_normal_900, expanded_obliqu_900 },
{ expanded_italic_100, expanded_italic_100 },
{ expanded_italic_900, expanded_italic_900 },
{ expanded_obliqu_100, expanded_obliqu_100 },
{ expanded_obliqu_900, expanded_obliqu_900 },
},
},
};
for (StyleSetTest& test : tests) {
for (const StyleSetTest::Case& testCase : test.cases) {
sk_sp<SkTypeface> typeface(test.styleSet.matchStyle(testCase.pattern));
if (typeface) {
REPORTER_ASSERT(reporter, typeface->fontStyle() == testCase.expectedResult);
} else {
REPORTER_ASSERT(reporter, invalidFontStyle == testCase.expectedResult);
}
}
}
}
DEFINE_bool(verboseFontMgr, false, "run verbose fontmgr tests.");
DEF_TEST(FontMgr, reporter) {
test_match(reporter);
test_matchStyleCSS3(reporter);
test_fontiter(reporter, FLAGS_verboseFontMgr);
test_alias_names(reporter);
test_font(reporter);
}
|
SECTION code_clib
SECTION code_l
PUBLIC l_fast_btoul
EXTERN l_fast_btou
l_fast_btoul:
; ascii binary string to unsigned long
; whitespace is not skipped
; char consumption stops on overflow
;
; enter : de = char *buffer
;
; exit : bc = & next char to interpret in buffer
; dehl = unsigned result (0 on invalid input, and % $ffffffff on overflow)
; carry set on unsigned overflow
;
; uses : af, bc, de, hl
call l_fast_btou ; try to do it in 16 bits
ld c,e
ld b,d
ld de,0
ret nc ; was 16 bits
; 32 bit loop
inc e
loop:
ld a,(bc)
; inlined isbdigit
sub '0'
ccf
ret nc
cp 2
ret nc
inc bc
rra
IF __CPU_INTEL__
push bc
ld c,a
ld a,l
adc l
ld l,a
ld a,h
adc h
ld h,a
ld a,e
rla
ld e,a
ld a,d
rla
ld d,a
ld a,c
pop bc
ELSE
adc hl,hl
rl e
rl d
ENDIF
jr nc, loop
ret
|
STDIN equ 0
STDOUT equ 1
SYS_EXIT equ 1
SYS_READ equ 3
SYS_WRITE equ 4
section .bss
result resb 1
section .text
global main
main:
mov al, 5 ;getting 5 in the AL register
mov bl, 3 ;getting 3 in the BL register
or al, bl ;or al and bl registers, result should be 7
add al, byte '0' ;convert decimal to ASCII
mov [result], al
mov eax, SYS_WRITE
mov ebx, STDOUT
mov ecx, result
mov edx, SYS_EXIT
int 0x80 |
#include "SwiftRuntimeFailureRecognizer.h"
#include "lldb/Core/Module.h"
#include "lldb/Symbol/Function.h"
#include "lldb/Symbol/SymbolContext.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/Target.h"
#include "lldb/Target/Thread.h"
#include "lldb/Utility/LLDBLog.h"
#include "lldb/Utility/Log.h"
using namespace llvm;
using namespace lldb;
using namespace lldb_private;
SwiftRuntimeFailureRecognizedStackFrame::
SwiftRuntimeFailureRecognizedStackFrame(StackFrameSP most_relevant_frame_sp,
StringRef stop_desc)
: m_most_relevant_frame(most_relevant_frame_sp) {
m_stop_desc = std::string(stop_desc);
}
lldb::RecognizedStackFrameSP SwiftRuntimeFailureFrameRecognizer::RecognizeFrame(
lldb::StackFrameSP frame_sp) {
if (frame_sp->GetFrameIndex())
return {};
ThreadSP thread_sp = frame_sp->GetThread();
ProcessSP process_sp = thread_sp->GetProcess();
StackFrameSP most_relevant_frame_sp = thread_sp->GetStackFrameAtIndex(1);
if (!most_relevant_frame_sp) {
Log *log = GetLog(LLDBLog::Unwind);
LLDB_LOG(
log,
"Swift Runtime Failure Recognizer: Hit unwinding bound (1 frame)!");
return {};
}
SymbolContext sc = frame_sp->GetSymbolContext(eSymbolContextEverything);
if (!sc.block)
return {};
// The runtime error is set as the function name in the inlined function info
// of frame #0 by the compiler (https://github.com/apple/swift/pull/29506)
const InlineFunctionInfo *inline_info = nullptr;
Block *inline_block = sc.block->GetContainingInlinedBlock();
if (!inline_block)
return {};
inline_info = sc.block->GetInlinedFunctionInfo();
if (!inline_info)
return {};
StringRef runtime_error = inline_info->GetName().AsCString();
if (runtime_error.empty())
return {};
return lldb::RecognizedStackFrameSP(
new SwiftRuntimeFailureRecognizedStackFrame(most_relevant_frame_sp,
runtime_error));
}
lldb::StackFrameSP
SwiftRuntimeFailureRecognizedStackFrame::GetMostRelevantFrame() {
return m_most_relevant_frame;
}
namespace lldb_private {
void RegisterSwiftRuntimeFailureRecognizer(Process &process) {
RegularExpressionSP module_regex_sp = nullptr;
RegularExpressionSP symbol_regex_sp(
new RegularExpression("Swift runtime failure"));
StackFrameRecognizerSP srf_recognizer_sp =
std::make_shared<SwiftRuntimeFailureFrameRecognizer>();
process.GetTarget().GetFrameRecognizerManager().AddRecognizer(
srf_recognizer_sp, module_regex_sp, symbol_regex_sp, false);
}
} // namespace lldb_private
|
; A156855: 2025n^2 - n.
; 2024,8098,18222,32396,50620,72894,99218,129592,164016,202490,245014,291588,342212,396886,455610,518384,585208,656082,731006,809980,893004,980078,1071202,1166376,1265600,1368874,1476198,1587572,1702996,1822470,1945994,2073568,2205192,2340866,2480590,2624364,2772188,2924062,3079986,3239960,3403984,3572058,3744182,3920356,4100580,4284854,4473178,4665552,4861976,5062450,5266974,5475548,5688172,5904846,6125570,6350344,6579168,6812042,7048966,7289940,7534964,7784038,8037162,8294336,8555560,8820834,9090158,9363532,9640956,9922430,10207954,10497528,10791152,11088826,11390550,11696324,12006148,12320022,12637946,12959920,13285944,13616018,13950142,14288316,14630540,14976814,15327138,15681512,16039936,16402410,16768934,17139508,17514132,17892806,18275530,18662304,19053128,19448002,19846926,20249900,20656924,21067998,21483122,21902296,22325520,22752794,23184118,23619492,24058916,24502390,24949914,25401488,25857112,26316786,26780510,27248284,27720108,28195982,28675906,29159880,29647904,30139978,30636102,31136276,31640500,32148774,32661098,33177472,33697896,34222370,34750894,35283468,35820092,36360766,36905490,37454264,38007088,38563962,39124886,39689860,40258884,40831958,41409082,41990256,42575480,43164754,43758078,44355452,44956876,45562350,46171874,46785448,47403072,48024746,48650470,49280244,49914068,50551942,51193866,51839840,52489864,53143938,53802062,54464236,55130460,55800734,56475058,57153432,57835856,58522330,59212854,59907428,60606052,61308726,62015450,62726224,63441048,64159922,64882846,65609820,66340844,67075918,67815042,68558216,69305440,70056714,70812038,71571412,72334836,73102310,73873834,74649408,75429032,76212706,77000430,77792204,78588028,79387902,80191826,80999800,81811824,82627898,83448022,84272196,85100420,85932694,86769018,87609392,88453816,89302290,90154814,91011388,91872012,92736686,93605410,94478184,95355008,96235882,97120806,98009780,98902804,99799878,100701002,101606176,102515400,103428674,104345998,105267372,106192796,107122270,108055794,108993368,109934992,110880666,111830390,112784164,113741988,114703862,115669786,116639760,117613784,118591858,119573982,120560156,121550380,122544654,123542978,124545352,125551776,126562250
mov $2,$0
add $0,1
mov $4,4
add $4,$2
sub $4,$0
mul $0,45
pow $0,2
mul $4,2
mov $6,$2
add $6,4
mov $1,$6
mov $7,9
sub $7,$4
lpb $0,1
add $0,$7
sub $0,$1
sub $0,1
mov $1,$0
mov $0,$5
pow $6,$3
add $1,$6
lpe
|
GLOBAL _cli
GLOBAL _sti
GLOBAL pic_master_mask
GLOBAL pic_slave_mask
GLOBAL halt
GLOBAL _irq00Handler
GLOBAL _irq01Handler
GLOBAL _irq80Handler
GLOBAL _exception00Handler
GLOBAL _exception06Handler
GLOBAL _exception13Handler
GLOBAL _exception14Handler
EXTERN irqDispatcher
EXTERN handleSyscall
EXTERN exceptionDispatcher
Extern printInteger
extern print
%macro pushState 0
push rax
push rbx
push rcx
push rdx
push rbp
push rdi
push rsi
push r8
push r9
push r10
push r11
push r12
push r13
push r14
push r15
push fs
push gs
%endmacro
%macro pushStateNoRAX 0
push rbx
push rcx
push rdx
push rbp
push rdi
push rsi
push r8
push r9
push r10
push r11
push r12
push r13
push r14
push r15
push fs
push gs
%endmacro
%macro popStateNoRAX 0
pop gs
pop fs
pop r15
pop r14
pop r13
pop r12
pop r11
pop r10
pop r9
pop r8
pop rsi
pop rdi
pop rbp
pop rdx
pop rcx
pop rbx
%endmacro
%macro popState 0
pop gs
pop fs
pop r15
pop r14
pop r13
pop r12
pop r11
pop r10
pop r9
pop r8
pop rsi
pop rdi
pop rbp
pop rdx
pop rcx
pop rbx
pop rax
%endmacro
%macro irqHandlerMaster 1
cli
pushState
mov rdi, %1 ; pasaje de parámetro
mov rsi, rsp
call irqDispatcher
; signal pic EOI (End of Interrupt)
mov al, 20h
out 20h, al
popState
sti
iretq
%endmacro
%macro exceptionHandlerMaster 1
pushState
mov rdi, %1
mov rsi, rsp
call exceptionDispatcher
mov al, 20h
out 20h, al
popState
iretq
%endmacro
_irq00Handler:
irqHandlerMaster 0
_irq01Handler:
irqHandlerMaster 1
_irq80Handler:
pushStateNoRAX
call handleSyscall
; signal pic EOI
;mov al, 20h
;out 20h, al
popStateNoRAX
iretq
_exception00Handler:
exceptionHandlerMaster 0
_exception06Handler:
exceptionHandlerMaster 6
_exception13Handler:
exceptionHandlerMaster 13
_exception14Handler:
exceptionHandlerMaster 14
_cli:
cli
ret
_sti:
sti
ret
halt: ;necesito el halt
hlt
ret
pic_master_mask:
push rbp
mov rbp, rsp
mov ax, di
out 21h,al
pop rbp
retn
pic_slave_mask:
push rbp
mov rbp, rsp
mov ax, di ; ax = mascara de 16 bits
out 0A1h,al
pop rbp
retn
|
# Test 3 - mult
pushd 2.6
pushd 3.86
mult
halt |
; int printf_unlocked(const char *format, ...)
SECTION code_clib
SECTION code_stdio
PUBLIC _printf_unlocked
EXTERN asm_printf_unlocked
defc _printf_unlocked = asm_printf_unlocked
|
; A312143: Coordination sequence Gal.5.55.2 where G.u.t.v denotes the coordination sequence for a vertex of type v in tiling number t in the Galebach list of u-uniform tilings.
; 1,4,8,13,18,23,28,33,38,42,46,50,54,59,64,69,74,79,84,88,92,96,100,105,110,115,120,125,130,134,138,142,146,151,156,161,166,171,176,180,184,188,192,197,202,207,212,217,222,226
mov $2,$0
mov $3,$0
mov $4,3
lpb $0
sub $0,1
add $5,$4
add $1,$5
trn $1,$3
mov $4,4
add $5,5
trn $3,$5
mov $5,3
sub $5,$1
trn $5,2
lpe
add $1,1
lpb $2
add $1,1
sub $2,1
lpe
mov $0,$1
|
OUTPUT "op_ED.bin"
in b,(c) ; #ED40
out (c),b ; #ED41
sbc hl,bc ; #ED42
ld (#100),bc ; #ED430001
neg ; #ED44
retn ; #ED45
im 0 ; #ED46
ld i,a ; #ED47
in c,(c) ; #ED48
out (c),c ; #ED49
adc hl,bc ; #ED4A
ld bc,(#100) ; #ED4B0001
reti ; #ED4D
ld r,a ; #ED4F
in d,(c) ; #ED50
out (c),d ; #ED51
sbc hl,de ; #ED52
ld (#100),de ; #ED530001
im 1 ; #ED56
ld a,i ; #ED57
in e,(c) ; #ED58
out (c),e ; #ED59
adc hl,de ; #ED5A
ld de,(#100) ; #ED5B0001
ld a,r ; #ED5F
in h,(c) ; #ED60
out (c),h ; #ED61
sbc hl,hl ; #ED62
rrd ; #ED67
in l,(c) ; #ED68
out (c),l ; #ED69
adc hl,hl ; #ED6A
rld ; #ED6F
in f,(c) ; #ED70
out (c),0 ; #ED71
sbc hl,sp ; #ED72
ld (#100),sp ; #ED730001
in a,(c) ; #ED78
out (c),a ; #ED79
adc hl,sp ; #ED7A
ld sp,(#100) ; #ED7B0001
ldi ; #EDA0
cpi ; #EDA1
ini ; #EDA2
outi ; #EDA3
ldd ; #EDA8
cpd ; #EDA9
ind ; #EDAA
outd ; #EDAB
ldir ; #EDB0
cpir ; #EDB1
inir ; #EDB2
otir ; #EDB3
lddr ; #EDB8
cpdr ; #EDB9
indr ; #EDBA
otdr ; #EDBB
|
#include "DataFormats/Common/interface/View.h"
#include <typeinfo>
namespace edm
{
//------------------------------------------------------------------
// Implementation of ViewBase.
//------------------------------------------------------------------
ViewBase::~ViewBase() { }
std::unique_ptr<ViewBase>
ViewBase::clone() const
{
auto p = doClone();
assert(typeid(*(p.get()))==typeid(*this) && "doClone() incorrectly overriden");
return p;
}
ViewBase::ViewBase() {}
ViewBase::ViewBase(ViewBase const&) { }
}
|
; Z88 Small C+ Run Time Library
; Long support functions
; "8080" mode
; Stefano - 30/4/2002
; $Id: l_long_ucmp.asm,v 1.2 2016-06-16 20:31:05 dom Exp $
;
SECTION code_crt0_sccz80
PUBLIC l_long_ucmp
; Unsigned compare of dehl (stack) and dehl (registers)
;
; Entry: primary = (under two return addresses on stack)
; secondary= dehl
;
; Exit: z = numbers the same
; nz = numbers different
; c/nc = sign of difference [set if secondary > primary]
;
; Code takes secondary from primary
.l_long_ucmp
ex (sp),hl
ld (retloc+1),hl
pop bc
ld hl,0
add hl,sp ;points to hl on stack
ld a,(hl)
sub c
inc hl
ld a,(hl)
sbc a,b
inc hl
ld a,(hl)
sbc a,e
inc hl
ld a,(hl)
sbc a,d
inc hl
ld sp,hl
;ld l,c ;get the lower 16 back into hl
;ld h,b
; ATP we have done the comparision and are left with dehl = result of
; primary - secondary, if we have a carry then secondary > primary
jr c,l_long_ucmp1 ;
; Primary was larger, return nc
ld a,h
or l
or d
or e
ld hl,1 ; Saves some mem in comparison functions
scf ; Replace with and a?
ccf
jr retloc
; Secondary was larger, return c
.l_long_ucmp1
ld a,h
or l
or d
or e
scf
ld hl,1 ; Saves some mem in comparision unfunctions
.retloc jp 0
|
; Sets OVER flag in P_FLAG permanently
; Parameter: OVER flag in bit 0 of A register
#include once <copy_attr.asm>
#include once <const.asm>
OVER:
PROC
ld c, a ; saves it for later
and 2
ld hl, FLAGS2
res 1, (HL)
or (hl)
ld (hl), a
ld a, c ; Recovers previous value
and 1 ; # Convert to 0/1
add a, a; # Shift left 1 bit for permanent
ld hl, P_FLAG
res 1, (hl)
or (hl)
ld (hl), a
ret
; Sets OVER flag in P_FLAG temporarily
OVER_TMP:
ld c, a ; saves it for later
and 2 ; gets bit 1; clears carry
rra
ld hl, FLAGS2
res 0, (hl)
or (hl)
ld (hl), a
ld a, c ; Recovers previous value
and 1
ld hl, P_FLAG
res 0, (hl)
ld (hl), a
jp __SET_ATTR_MODE
ENDP
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.