Compare commits
88 Commits
llvmorg-4.
...
llvmorg-2.
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
442d5f5ea8 | ||
|
|
e627096cda | ||
|
|
6fe352c904 | ||
|
|
1c88ffb68a | ||
|
|
d51a6f1a95 | ||
|
|
aee09631c1 | ||
|
|
43012b0b19 | ||
|
|
6f46e545d2 | ||
|
|
b2d5a6d2e1 | ||
|
|
18949d7bf3 | ||
|
|
2b7025e0b9 | ||
|
|
49a9f7ff81 | ||
|
|
3eb9382be8 | ||
|
|
aea386fd7b | ||
|
|
a590c6555b | ||
|
|
c61881e78d | ||
|
|
c47a943d7b | ||
|
|
318048b288 | ||
|
|
dfa842c4ae | ||
|
|
2622b3d983 | ||
|
|
518c626dd0 | ||
|
|
2d6c8c3fc2 | ||
|
|
a634991419 | ||
|
|
fea943141a | ||
|
|
ad894c510c | ||
|
|
19e385aa8b | ||
|
|
bdf147f759 | ||
|
|
4414586d8d | ||
|
|
54bacabe76 | ||
|
|
26116ab563 | ||
|
|
520e9abf42 | ||
|
|
eea0470f60 | ||
|
|
30d355ad11 | ||
|
|
cdf29d86e1 | ||
|
|
bf060dafac | ||
|
|
aea2a460fd | ||
|
|
2bf6141de9 | ||
|
|
df08efc3da | ||
|
|
c82b6db8f5 | ||
|
|
eddd1d69a6 | ||
|
|
43a93e5b23 | ||
|
|
b1cf1a6d3c | ||
|
|
b50bd81dd3 | ||
|
|
f386982e3a | ||
|
|
642a39bed2 | ||
|
|
d7a5015ad8 | ||
|
|
e7ccbb6c71 | ||
|
|
3df11f7938 | ||
|
|
1f2e5e95d6 | ||
|
|
28f2f184fa | ||
|
|
571a5fc12f | ||
|
|
d92654ae23 | ||
|
|
e7392a0977 | ||
|
|
96e93c8091 | ||
|
|
d56acabbac | ||
|
|
92aacbb819 | ||
|
|
bf783c32f8 | ||
|
|
03513021ce | ||
|
|
360c61aa63 | ||
|
|
69bf0dce0c | ||
|
|
bfae06b37e | ||
|
|
3e549f5bb4 | ||
|
|
62d32739f7 | ||
|
|
d1d0e8bcff | ||
|
|
8c223dca47 | ||
|
|
bc66891818 | ||
|
|
311c6eb7c1 | ||
|
|
dca066cc47 | ||
|
|
689802f7c8 | ||
|
|
b89763dd05 | ||
|
|
c0add56152 | ||
|
|
14c9ed11e7 | ||
|
|
7ce8662888 | ||
|
|
c52000b643 | ||
|
|
11cec56713 | ||
|
|
27035f0fe9 | ||
|
|
1a289c3581 | ||
|
|
1566c709cd | ||
|
|
08da67fbbf | ||
|
|
991cf4d8d5 | ||
|
|
1c7ce21228 | ||
|
|
d2eb189208 | ||
|
|
169347b6c6 | ||
|
|
685b503ff6 | ||
|
|
ad88af3412 | ||
|
|
e698978712 | ||
|
|
7858b96d51 | ||
|
|
8324076c30 |
49
clang/INSTALL.txt
Normal file
49
clang/INSTALL.txt
Normal file
@@ -0,0 +1,49 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
// Clang Installation Instructions
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
These instructions describe how to build and install Clang.
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// Step 1: Organization
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
Clang is designed to be built as part of an LLVM build. Assuming that the LLVM
|
||||
source code is located at $LLVM_SRC_ROOT, then the clang source code should be
|
||||
installed as:
|
||||
|
||||
$LLVM_SRC_ROOT/tools/clang
|
||||
|
||||
The directory is not required to be called clang, but doing so will allow the
|
||||
LLVM build system to automatically recognize it and build it along with LLVM.
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// Step 2: Configure and Build LLVM
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
Configure and build your copy of LLVM (see $LLVM_SRC_ROOT/GettingStarted.html
|
||||
for more information).
|
||||
|
||||
Assuming you installed clang at $LLVM_SRC_ROOT/tools/clang then Clang will
|
||||
automatically be built with LLVM. Otherwise, run 'make' in the Clang source
|
||||
directory to build Clang.
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// Step 3: (Optional) Verify Your Build
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
It is a good idea to run the Clang tests to make sure your build works
|
||||
correctly. From inside the Clang build directory, run 'make test' to run the
|
||||
tests.
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// Step 4: Install Clang
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
From inside the Clang build directory, run 'make install' to install the Clang
|
||||
compiler and header files into the prefix directory selected when LLVM was
|
||||
configured.
|
||||
|
||||
The Clang compiler is available as 'clang' and supports a gcc like command line
|
||||
interface. See the man page for clang (installed into $prefix/share/man/man1)
|
||||
for more information.
|
||||
@@ -378,8 +378,7 @@ Show commands to run and use verbose output.
|
||||
|
||||
=over
|
||||
|
||||
=item
|
||||
B<-fshow-column>
|
||||
=item B<-fshow-column>
|
||||
B<-fshow-source-location>
|
||||
B<-fcaret-diagnostics>
|
||||
B<-fdiagnostics-fixit-info>
|
||||
@@ -428,13 +427,14 @@ Do not search the standard system directories for include files.
|
||||
=cut
|
||||
|
||||
## TODO, but do we really want people using this stuff?
|
||||
=item B<-idirafter>I<directory>
|
||||
=item B<-iquote>I<directory>
|
||||
=item B<-isystem>I<directory>
|
||||
=item B<-iprefix>I<directory>
|
||||
=item B<-iwithprefix>I<directory>
|
||||
=item B<-iwithprefixbefore>I<directory>
|
||||
=item B<-isysroot>
|
||||
#=item B<-idirafter>I<directory>
|
||||
#=item B<-iquote>I<directory>
|
||||
#=item B<-isystem>I<directory>
|
||||
#=item B<-iprefix>I<directory>
|
||||
#=item B<-iwithprefix>I<directory>
|
||||
#=item B<-iwithprefixbefore>I<directory>
|
||||
#=item B<-isysroot>
|
||||
|
||||
=pod
|
||||
|
||||
|
||||
@@ -445,21 +445,21 @@ Do not search the standard system directories for include files.
|
||||
=cut
|
||||
|
||||
### TODO someday.
|
||||
=head2 Warning Control Options
|
||||
=over
|
||||
=back
|
||||
=head2 Code Generation and Optimization Options
|
||||
=over
|
||||
=back
|
||||
=head2 Assembler Options
|
||||
=over
|
||||
=back
|
||||
=head2 Linker Options
|
||||
=over
|
||||
=back
|
||||
=head2 Static Analyzer Options
|
||||
=over
|
||||
=back
|
||||
#=head2 Warning Control Options
|
||||
#=over
|
||||
#=back
|
||||
#=head2 Code Generation and Optimization Options
|
||||
#=over
|
||||
#=back
|
||||
#=head2 Assembler Options
|
||||
#=over
|
||||
#=back
|
||||
#=head2 Linker Options
|
||||
#=over
|
||||
#=back
|
||||
#=head2 Static Analyzer Options
|
||||
#=over
|
||||
#=back
|
||||
|
||||
=pod
|
||||
|
||||
|
||||
@@ -286,10 +286,12 @@ protected:
|
||||
/// argument.
|
||||
struct UnparsedDefaultArgument;
|
||||
|
||||
typedef llvm::PointerUnion3<Stmt *, EvaluatedStmt *,
|
||||
UnparsedDefaultArgument *> InitType;
|
||||
|
||||
/// \brief The initializer for this variable or, for a ParmVarDecl, the
|
||||
/// C++ default argument.
|
||||
mutable llvm::PointerUnion3<Stmt *, EvaluatedStmt *, UnparsedDefaultArgument*>
|
||||
Init;
|
||||
mutable InitType Init;
|
||||
|
||||
private:
|
||||
// FIXME: This can be packed into the bitfields in Decl.
|
||||
@@ -363,7 +365,15 @@ public:
|
||||
Stmt **getInitAddress() {
|
||||
if (EvaluatedStmt *ES = Init.dyn_cast<EvaluatedStmt*>())
|
||||
return &ES->Value;
|
||||
return reinterpret_cast<Stmt **>(&Init); // FIXME: ugly hack
|
||||
|
||||
// This union hack tip-toes around strict-aliasing rules.
|
||||
union {
|
||||
InitType *InitPtr;
|
||||
Stmt **StmtPtr;
|
||||
};
|
||||
|
||||
InitPtr = &Init;
|
||||
return StmtPtr;
|
||||
}
|
||||
|
||||
void setInit(ASTContext &C, Expr *I);
|
||||
|
||||
@@ -38,7 +38,7 @@ public:
|
||||
TypeLoc() : Data(0) { }
|
||||
|
||||
bool isNull() const { return Ty.isNull(); }
|
||||
operator bool() const { return isNull(); }
|
||||
operator bool() const { return !isNull(); }
|
||||
|
||||
/// \brief Returns the size of type source info data block for the given type.
|
||||
static unsigned getFullDataSizeForType(QualType Ty);
|
||||
|
||||
@@ -16,6 +16,9 @@ LIBRARYNAME := clangAST
|
||||
BUILD_ARCHIVE = 1
|
||||
CXXFLAGS = -fno-rtti
|
||||
|
||||
# Don't install Clang libraries
|
||||
NO_INSTALL = 1
|
||||
|
||||
CPPFLAGS += -I$(PROJ_SRC_DIR)/../../include -I$(PROJ_OBJ_DIR)/../../include
|
||||
|
||||
include $(LEVEL)/Makefile.common
|
||||
|
||||
@@ -16,6 +16,9 @@ LIBRARYNAME := clangAnalysis
|
||||
BUILD_ARCHIVE = 1
|
||||
CXXFLAGS = -fno-rtti
|
||||
|
||||
# Don't install Clang libraries
|
||||
NO_INSTALL = 1
|
||||
|
||||
CPPFLAGS += -I$(PROJ_SRC_DIR)/../../include -I$(PROJ_OBJ_DIR)/../../include
|
||||
|
||||
include $(LEVEL)/Makefile.common
|
||||
|
||||
@@ -293,6 +293,7 @@ int MemorizeStatCalls::stat(const char *path, struct stat *buf) {
|
||||
if (result != 0) {
|
||||
// Cache failed 'stat' results.
|
||||
struct stat empty;
|
||||
memset(&empty, 0, sizeof(empty));
|
||||
StatCalls[path] = StatResult(result, empty);
|
||||
}
|
||||
else if (!S_ISDIR(buf->st_mode) || llvm::sys::Path(path).isAbsolute()) {
|
||||
|
||||
@@ -16,6 +16,9 @@ LIBRARYNAME := clangBasic
|
||||
BUILD_ARCHIVE = 1
|
||||
CXXFLAGS = -fno-rtti
|
||||
|
||||
# Don't install Clang libraries
|
||||
NO_INSTALL = 1
|
||||
|
||||
CPPFLAGS += -I$(PROJ_SRC_DIR)/../../include -I$(PROJ_OBJ_DIR)/../../include
|
||||
|
||||
include $(LEVEL)/Makefile.common
|
||||
|
||||
@@ -28,14 +28,13 @@ using namespace CodeGen;
|
||||
|
||||
void CGRecordLayoutBuilder::Layout(const RecordDecl *D) {
|
||||
Alignment = Types.getContext().getASTRecordLayout(D).getAlignment() / 8;
|
||||
Packed = D->hasAttr<PackedAttr>();
|
||||
|
||||
if (D->isUnion()) {
|
||||
LayoutUnion(D);
|
||||
return;
|
||||
}
|
||||
|
||||
Packed = D->hasAttr<PackedAttr>();
|
||||
|
||||
if (LayoutFields(D))
|
||||
return;
|
||||
|
||||
@@ -200,8 +199,15 @@ void CGRecordLayoutBuilder::LayoutUnion(const RecordDecl *D) {
|
||||
}
|
||||
|
||||
// Now add our field.
|
||||
if (Ty)
|
||||
if (Ty) {
|
||||
AppendField(0, Ty);
|
||||
|
||||
if (getTypeAlignment(Ty) > Layout.getAlignment() / 8) {
|
||||
// We need a packed struct.
|
||||
Packed = true;
|
||||
Align = 1;
|
||||
}
|
||||
}
|
||||
|
||||
// Append tail padding.
|
||||
if (Layout.getSize() / 8 > Size)
|
||||
|
||||
@@ -17,6 +17,9 @@ LIBRARYNAME := clangCodeGen
|
||||
BUILD_ARCHIVE = 1
|
||||
CXXFLAGS = -fno-rtti
|
||||
|
||||
# Don't install Clang libraries
|
||||
NO_INSTALL = 1
|
||||
|
||||
CPPFLAGS += -I$(PROJ_SRC_DIR)/../../include -I$(PROJ_OBJ_DIR)/../../include
|
||||
|
||||
include $(LEVEL)/Makefile.common
|
||||
|
||||
@@ -37,6 +37,9 @@
|
||||
using namespace clang::driver;
|
||||
using namespace clang;
|
||||
|
||||
// Used to set values for "production" clang, for releases.
|
||||
#define USE_PRODUCTION_CLANG
|
||||
|
||||
Driver::Driver(const char *_Name, const char *_Dir,
|
||||
const char *_DefaultHostTriple,
|
||||
const char *_DefaultImageName,
|
||||
@@ -46,10 +49,20 @@ Driver::Driver(const char *_Name, const char *_Dir,
|
||||
DefaultImageName(_DefaultImageName),
|
||||
Host(0),
|
||||
CCCIsCXX(false), CCCEcho(false), CCCPrintBindings(false),
|
||||
CCCGenericGCCName("gcc"), CCCUseClang(true), CCCUseClangCXX(true),
|
||||
CCCGenericGCCName("gcc"), CCCUseClang(true),
|
||||
#ifdef USE_PRODUCTION_CLANG
|
||||
CCCUseClangCXX(false),
|
||||
#else
|
||||
CCCUseClangCXX(true),
|
||||
#endif
|
||||
CCCUseClangCPP(true), CCCUsePCH(true),
|
||||
SuppressMissingInputWarning(false)
|
||||
{
|
||||
#ifdef USE_PRODUCTION_CLANG
|
||||
// Only use clang on i386 and x86_64 by default, in a "production" build.
|
||||
CCCClangArchs.insert("i386");
|
||||
CCCClangArchs.insert("x86_64");
|
||||
#endif
|
||||
}
|
||||
|
||||
Driver::~Driver() {
|
||||
|
||||
@@ -12,6 +12,8 @@ LIBRARYNAME := clangDriver
|
||||
BUILD_ARCHIVE = 1
|
||||
CXXFLAGS = -fno-rtti
|
||||
|
||||
# Don't install Clang libraries
|
||||
NO_INSTALL = 1
|
||||
|
||||
include $(LEVEL)/Makefile.common
|
||||
|
||||
|
||||
@@ -211,7 +211,9 @@ static void DefineTypeSize(const char *MacroName, unsigned TypeWidth,
|
||||
else
|
||||
MaxVal = ~0LL >> (64-TypeWidth);
|
||||
|
||||
sprintf(MacroBuf, "%s=%llu%s", MacroName, MaxVal, ValSuffix);
|
||||
// FIXME: Switch to using raw_ostream and avoid utostr().
|
||||
sprintf(MacroBuf, "%s=%s%s", MacroName, llvm::utostr(MaxVal).c_str(),
|
||||
ValSuffix);
|
||||
DefineBuiltinMacro(Buf, MacroBuf);
|
||||
}
|
||||
|
||||
|
||||
@@ -12,6 +12,9 @@ LIBRARYNAME := clangFrontend
|
||||
BUILD_ARCHIVE = 1
|
||||
CXXFLAGS = -fno-rtti
|
||||
|
||||
# Don't install Clang libraries
|
||||
NO_INSTALL = 1
|
||||
|
||||
CPPFLAGS += -I$(PROJ_SRC_DIR)/../../include -I$(PROJ_OBJ_DIR)/../../include
|
||||
|
||||
include $(LEVEL)/Makefile.common
|
||||
|
||||
@@ -2215,6 +2215,7 @@ void PCHReader::InitializeSema(Sema &S) {
|
||||
for (unsigned I = 0, N = TentativeDefinitions.size(); I != N; ++I) {
|
||||
VarDecl *Var = cast<VarDecl>(GetDecl(TentativeDefinitions[I]));
|
||||
SemaObj->TentativeDefinitions[Var->getDeclName()] = Var;
|
||||
SemaObj->TentativeDefinitionList.push_back(Var->getDeclName());
|
||||
}
|
||||
|
||||
// If there were any locally-scoped external declarations,
|
||||
|
||||
@@ -1799,19 +1799,22 @@ void PCHWriter::WritePCH(Sema &SemaRef, MemorizeStatCalls *StatCalls,
|
||||
getIdentifierRef(&Table.get(BuiltinNames[I]));
|
||||
}
|
||||
|
||||
// Build a record containing all of the tentative definitions in
|
||||
// this header file. Generally, this record will be empty.
|
||||
// Build a record containing all of the tentative definitions in this file, in
|
||||
// TentativeDefinitionList order. Generally, this record will be empty for
|
||||
// headers.
|
||||
RecordData TentativeDefinitions;
|
||||
for (llvm::DenseMap<DeclarationName, VarDecl *>::iterator
|
||||
TD = SemaRef.TentativeDefinitions.begin(),
|
||||
TDEnd = SemaRef.TentativeDefinitions.end();
|
||||
TD != TDEnd; ++TD)
|
||||
AddDeclRef(TD->second, TentativeDefinitions);
|
||||
for (unsigned i = 0, e = SemaRef.TentativeDefinitionList.size(); i != e; ++i){
|
||||
VarDecl *VD =
|
||||
SemaRef.TentativeDefinitions.lookup(SemaRef.TentativeDefinitionList[i]);
|
||||
if (VD) AddDeclRef(VD, TentativeDefinitions);
|
||||
}
|
||||
|
||||
// Build a record containing all of the locally-scoped external
|
||||
// declarations in this header file. Generally, this record will be
|
||||
// empty.
|
||||
RecordData LocallyScopedExternalDecls;
|
||||
// FIXME: This is filling in the PCH file in densemap order which is
|
||||
// nondeterminstic!
|
||||
for (llvm::DenseMap<DeclarationName, NamedDecl *>::iterator
|
||||
TD = SemaRef.LocallyScopedExternalDecls.begin(),
|
||||
TDEnd = SemaRef.LocallyScopedExternalDecls.end();
|
||||
|
||||
@@ -18,6 +18,9 @@ LIBRARYNAME := clangIndex
|
||||
BUILD_ARCHIVE = 1
|
||||
CXXFLAGS = -fno-rtti
|
||||
|
||||
# Don't install Clang libraries
|
||||
NO_INSTALL = 1
|
||||
|
||||
ifeq ($(ARCH),PowerPC)
|
||||
CXXFLAGS += -maltivec
|
||||
endif
|
||||
|
||||
@@ -18,6 +18,9 @@ LIBRARYNAME := clangLex
|
||||
BUILD_ARCHIVE = 1
|
||||
CXXFLAGS = -fno-rtti
|
||||
|
||||
# Don't install Clang libraries
|
||||
NO_INSTALL = 1
|
||||
|
||||
ifeq ($(ARCH),PowerPC)
|
||||
CXXFLAGS += -maltivec
|
||||
endif
|
||||
|
||||
@@ -16,6 +16,9 @@ LIBRARYNAME := clangParse
|
||||
BUILD_ARCHIVE = 1
|
||||
CXXFLAGS = -fno-rtti
|
||||
|
||||
# Don't install Clang libraries
|
||||
NO_INSTALL = 1
|
||||
|
||||
CPPFLAGS += -I$(PROJ_SRC_DIR)/../../include -I$(PROJ_OBJ_DIR)/../../include
|
||||
|
||||
include $(LEVEL)/Makefile.common
|
||||
|
||||
@@ -16,6 +16,9 @@ LIBRARYNAME := clangRewrite
|
||||
BUILD_ARCHIVE = 1
|
||||
CXXFLAGS = -fno-rtti
|
||||
|
||||
# Don't install Clang libraries
|
||||
NO_INSTALL = 1
|
||||
|
||||
CPPFLAGS += -I$(PROJ_SRC_DIR)/../../include -I$(PROJ_OBJ_DIR)/../../include
|
||||
|
||||
include $(LEVEL)/Makefile.common
|
||||
|
||||
@@ -17,6 +17,9 @@ LIBRARYNAME := clangSema
|
||||
BUILD_ARCHIVE = 1
|
||||
CXXFLAGS = -fno-rtti
|
||||
|
||||
# Don't install Clang libraries
|
||||
NO_INSTALL = 1
|
||||
|
||||
CPPFLAGS += -I$(PROJ_SRC_DIR)/../../include -I$(PROJ_OBJ_DIR)/../../include
|
||||
|
||||
include $(LEVEL)/Makefile.common
|
||||
|
||||
@@ -247,13 +247,16 @@ void Sema::ActOnEndOfTranslationUnit() {
|
||||
// template instantiations earlier.
|
||||
PerformPendingImplicitInstantiations();
|
||||
|
||||
// check for #pragma weak identifiers that were never declared
|
||||
// Check for #pragma weak identifiers that were never declared
|
||||
// FIXME: This will cause diagnostics to be emitted in a non-determinstic
|
||||
// order! Iterating over a densemap like this is bad.
|
||||
for (llvm::DenseMap<IdentifierInfo*,WeakInfo>::iterator
|
||||
I = WeakUndeclaredIdentifiers.begin(),
|
||||
E = WeakUndeclaredIdentifiers.end(); I != E; ++I) {
|
||||
if (!I->second.getUsed())
|
||||
Diag(I->second.getLocation(), diag::warn_weak_identifier_undeclared)
|
||||
<< I->first;
|
||||
I = WeakUndeclaredIdentifiers.begin(),
|
||||
E = WeakUndeclaredIdentifiers.end(); I != E; ++I) {
|
||||
if (I->second.getUsed()) continue;
|
||||
|
||||
Diag(I->second.getLocation(), diag::warn_weak_identifier_undeclared)
|
||||
<< I->first;
|
||||
}
|
||||
|
||||
if (!CompleteTranslationUnit)
|
||||
@@ -270,31 +273,30 @@ void Sema::ActOnEndOfTranslationUnit() {
|
||||
// translation unit contains a file scope declaration of that
|
||||
// identifier, with the composite type as of the end of the
|
||||
// translation unit, with an initializer equal to 0.
|
||||
for (llvm::DenseMap<DeclarationName, VarDecl *>::iterator
|
||||
D = TentativeDefinitions.begin(),
|
||||
DEnd = TentativeDefinitions.end();
|
||||
D != DEnd; ++D) {
|
||||
VarDecl *VD = D->second;
|
||||
|
||||
if (VD->isInvalidDecl() || !VD->isTentativeDefinition(Context))
|
||||
for (unsigned i = 0, e = TentativeDefinitionList.size(); i != e; ++i) {
|
||||
VarDecl *VD = TentativeDefinitions.lookup(TentativeDefinitionList[i]);
|
||||
|
||||
// If the tentative definition was completed, it will be in the list, but
|
||||
// not the map.
|
||||
if (VD == 0 || VD->isInvalidDecl() || !VD->isTentativeDefinition(Context))
|
||||
continue;
|
||||
|
||||
if (const IncompleteArrayType *ArrayT
|
||||
= Context.getAsIncompleteArrayType(VD->getType())) {
|
||||
if (RequireCompleteType(VD->getLocation(),
|
||||
ArrayT->getElementType(),
|
||||
diag::err_tentative_def_incomplete_type_arr))
|
||||
diag::err_tentative_def_incomplete_type_arr)) {
|
||||
VD->setInvalidDecl();
|
||||
else {
|
||||
// Set the length of the array to 1 (C99 6.9.2p5).
|
||||
Diag(VD->getLocation(), diag::warn_tentative_incomplete_array);
|
||||
llvm::APInt One(Context.getTypeSize(Context.getSizeType()),
|
||||
true);
|
||||
QualType T
|
||||
= Context.getConstantArrayWithoutExprType(ArrayT->getElementType(),
|
||||
One, ArrayType::Normal, 0);
|
||||
VD->setType(T);
|
||||
continue;
|
||||
}
|
||||
|
||||
// Set the length of the array to 1 (C99 6.9.2p5).
|
||||
Diag(VD->getLocation(), diag::warn_tentative_incomplete_array);
|
||||
llvm::APInt One(Context.getTypeSize(Context.getSizeType()), true);
|
||||
QualType T
|
||||
= Context.getConstantArrayWithoutExprType(ArrayT->getElementType(),
|
||||
One, ArrayType::Normal, 0);
|
||||
VD->setType(T);
|
||||
} else if (RequireCompleteType(VD->getLocation(), VD->getType(),
|
||||
diag::err_tentative_def_incomplete_type))
|
||||
VD->setInvalidDecl();
|
||||
|
||||
@@ -265,6 +265,7 @@ public:
|
||||
/// declaration, and only the most recent tentative declaration for
|
||||
/// a given variable will be recorded here.
|
||||
llvm::DenseMap<DeclarationName, VarDecl *> TentativeDefinitions;
|
||||
std::vector<DeclarationName> TentativeDefinitionList;
|
||||
|
||||
/// WeakUndeclaredIdentifiers - Identifiers contained in
|
||||
/// #pragma weak before declared. rare. may alias another
|
||||
@@ -1355,7 +1356,8 @@ public:
|
||||
|
||||
/// LookupInstanceMethodInGlobalPool - Returns the method and warns if
|
||||
/// there are multiple signatures.
|
||||
ObjCMethodDecl *LookupInstanceMethodInGlobalPool(Selector Sel, SourceRange R);
|
||||
ObjCMethodDecl *LookupInstanceMethodInGlobalPool(Selector Sel, SourceRange R,
|
||||
bool warn=true);
|
||||
|
||||
/// LookupFactoryMethodInGlobalPool - Returns the method and warns if
|
||||
/// there are multiple signatures.
|
||||
|
||||
@@ -3182,11 +3182,8 @@ void Sema::AddInitializerToDecl(DeclPtrTy dcl, ExprArg init, bool DirectInit) {
|
||||
// remove it from the set of tentative definitions.
|
||||
if (VDecl->getPreviousDeclaration() &&
|
||||
VDecl->getPreviousDeclaration()->isTentativeDefinition(Context)) {
|
||||
llvm::DenseMap<DeclarationName, VarDecl *>::iterator Pos
|
||||
= TentativeDefinitions.find(VDecl->getDeclName());
|
||||
assert(Pos != TentativeDefinitions.end() &&
|
||||
"Unrecorded tentative definition?");
|
||||
TentativeDefinitions.erase(Pos);
|
||||
bool Deleted = TentativeDefinitions.erase(VDecl->getDeclName());
|
||||
assert(Deleted && "Unrecorded tentative definition?"); Deleted=Deleted;
|
||||
}
|
||||
|
||||
return;
|
||||
@@ -3204,8 +3201,20 @@ void Sema::ActOnUninitializedDecl(DeclPtrTy dcl,
|
||||
QualType Type = Var->getType();
|
||||
|
||||
// Record tentative definitions.
|
||||
if (Var->isTentativeDefinition(Context))
|
||||
TentativeDefinitions[Var->getDeclName()] = Var;
|
||||
if (Var->isTentativeDefinition(Context)) {
|
||||
std::pair<llvm::DenseMap<DeclarationName, VarDecl *>::iterator, bool>
|
||||
InsertPair =
|
||||
TentativeDefinitions.insert(std::make_pair(Var->getDeclName(), Var));
|
||||
|
||||
// Keep the latest definition in the map. If we see 'int i; int i;' we
|
||||
// want the second one in the map.
|
||||
InsertPair.first->second = Var;
|
||||
|
||||
// However, for the list, we don't care about the order, just make sure
|
||||
// that there are no dupes for a given declaration name.
|
||||
if (InsertPair.second)
|
||||
TentativeDefinitionList.push_back(Var->getDeclName());
|
||||
}
|
||||
|
||||
// C++ [dcl.init.ref]p3:
|
||||
// The initializer can be omitted for a reference only in a
|
||||
|
||||
@@ -1264,7 +1264,8 @@ void Sema::AddInstanceMethodToGlobalPool(ObjCMethodDecl *Method) {
|
||||
|
||||
// FIXME: Finish implementing -Wno-strict-selector-match.
|
||||
ObjCMethodDecl *Sema::LookupInstanceMethodInGlobalPool(Selector Sel,
|
||||
SourceRange R) {
|
||||
SourceRange R,
|
||||
bool warn) {
|
||||
llvm::DenseMap<Selector, ObjCMethodList>::iterator Pos
|
||||
= InstanceMethodPool.find(Sel);
|
||||
if (Pos == InstanceMethodPool.end()) {
|
||||
@@ -1281,7 +1282,7 @@ ObjCMethodDecl *Sema::LookupInstanceMethodInGlobalPool(Selector Sel,
|
||||
for (ObjCMethodList *Next = MethList.Next; Next; Next = Next->Next)
|
||||
// This checks if the methods differ by size & alignment.
|
||||
if (!MatchTwoMethodDeclarations(MethList.Method, Next->Method, true))
|
||||
issueWarning = true;
|
||||
issueWarning = warn;
|
||||
}
|
||||
if (issueWarning && (MethList.Method && MethList.Next)) {
|
||||
Diag(R.getBegin(), diag::warn_multiple_method_decl) << Sel << R;
|
||||
|
||||
@@ -3213,9 +3213,9 @@ QualType Sema::CheckConditionalOperands(Expr *&Cond, Expr *&LHS, Expr *&RHS,
|
||||
// FIXME: Consider unifying with 'areComparableObjCPointerTypes'.
|
||||
// It could return the composite type.
|
||||
if (Context.canAssignObjCInterfaces(LHSOPT, RHSOPT)) {
|
||||
compositeType = LHSTy;
|
||||
compositeType = RHSOPT->isObjCBuiltinType() ? RHSTy : LHSTy;
|
||||
} else if (Context.canAssignObjCInterfaces(RHSOPT, LHSOPT)) {
|
||||
compositeType = RHSTy;
|
||||
compositeType = LHSOPT->isObjCBuiltinType() ? LHSTy : RHSTy;
|
||||
} else if ((LHSTy->isObjCQualifiedIdType() ||
|
||||
RHSTy->isObjCQualifiedIdType()) &&
|
||||
Context.ObjCQualifiedIdTypesAreCompatible(LHSTy, RHSTy, true)) {
|
||||
@@ -4350,31 +4350,33 @@ QualType Sema::CheckCompareOperands(Expr *&lex, Expr *&rex, SourceLocation Loc,
|
||||
return ResultTy;
|
||||
}
|
||||
if (lType->isObjCObjectPointerType() && rType->isObjCObjectPointerType()) {
|
||||
if (!Context.areComparableObjCPointerTypes(lType, rType)) {
|
||||
if (!Context.areComparableObjCPointerTypes(lType, rType))
|
||||
Diag(Loc, diag::ext_typecheck_comparison_of_distinct_pointers)
|
||||
<< lType << rType << lex->getSourceRange() << rex->getSourceRange();
|
||||
}
|
||||
ImpCastExprToType(rex, lType);
|
||||
return ResultTy;
|
||||
}
|
||||
}
|
||||
if (lType->isAnyPointerType() && rType->isIntegerType()) {
|
||||
if (isRelational)
|
||||
Diag(Loc, diag::ext_typecheck_ordered_comparison_of_pointer_integer)
|
||||
<< lType << rType << lex->getSourceRange() << rex->getSourceRange();
|
||||
else if (!RHSIsNull)
|
||||
Diag(Loc, diag::ext_typecheck_comparison_of_pointer_integer)
|
||||
if (!RHSIsNull) {
|
||||
unsigned DiagID = isRelational
|
||||
? diag::ext_typecheck_ordered_comparison_of_pointer_integer
|
||||
: diag::ext_typecheck_comparison_of_pointer_integer;
|
||||
Diag(Loc, DiagID)
|
||||
<< lType << rType << lex->getSourceRange() << rex->getSourceRange();
|
||||
}
|
||||
ImpCastExprToType(rex, lType); // promote the integer to pointer
|
||||
return ResultTy;
|
||||
}
|
||||
if (lType->isIntegerType() && rType->isAnyPointerType()) {
|
||||
if (isRelational)
|
||||
Diag(Loc, diag::ext_typecheck_ordered_comparison_of_pointer_integer)
|
||||
<< lType << rType << lex->getSourceRange() << rex->getSourceRange();
|
||||
else if (!LHSIsNull)
|
||||
Diag(Loc, diag::ext_typecheck_comparison_of_pointer_integer)
|
||||
if (!LHSIsNull) {
|
||||
unsigned DiagID = isRelational
|
||||
? diag::ext_typecheck_ordered_comparison_of_pointer_integer
|
||||
: diag::ext_typecheck_comparison_of_pointer_integer;
|
||||
|
||||
Diag(Loc, DiagID)
|
||||
<< lType << rType << lex->getSourceRange() << rex->getSourceRange();
|
||||
}
|
||||
ImpCastExprToType(lex, rType); // promote the integer to pointer
|
||||
return ResultTy;
|
||||
}
|
||||
|
||||
@@ -132,7 +132,7 @@ Sema::ExprResult Sema::ParseObjCSelectorExpression(Selector Sel,
|
||||
SourceLocation LParenLoc,
|
||||
SourceLocation RParenLoc) {
|
||||
ObjCMethodDecl *Method = LookupInstanceMethodInGlobalPool(Sel,
|
||||
SourceRange(LParenLoc, RParenLoc));
|
||||
SourceRange(LParenLoc, RParenLoc), false);
|
||||
if (!Method)
|
||||
Method = LookupFactoryMethodInGlobalPool(Sel,
|
||||
SourceRange(LParenLoc, RParenLoc));
|
||||
|
||||
@@ -1318,7 +1318,7 @@ Sema::GetDeclaratorInfoForDeclarator(Declarator &D, QualType T, unsigned Skip) {
|
||||
} else {
|
||||
//FIXME: Other typespecs.
|
||||
DefaultTypeSpecLoc &DTL = cast<DefaultTypeSpecLoc>(CurrTL);
|
||||
DTL.setStartLoc(D.getDeclSpec().getTypeSpecTypeLoc());
|
||||
DTL.setStartLoc(D.getDeclSpec().getSourceRange().getBegin());
|
||||
}
|
||||
|
||||
return DInfo;
|
||||
|
||||
@@ -1164,13 +1164,11 @@ public:
|
||||
SourceLocation LParenLoc,
|
||||
ExprArg SubExpr,
|
||||
SourceLocation RParenLoc) {
|
||||
Expr *Sub = SubExpr.takeAs<Expr>();
|
||||
void *Sub = SubExpr.takeAs<Expr>();
|
||||
return getSema().ActOnCXXTypeConstructExpr(TypeRange,
|
||||
T.getAsOpaquePtr(),
|
||||
LParenLoc,
|
||||
Sema::MultiExprArg(getSema(),
|
||||
(void **)&Sub,
|
||||
1),
|
||||
Sema::MultiExprArg(getSema(), &Sub, 1),
|
||||
/*CommaLocs=*/0,
|
||||
RParenLoc);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
// RUN: clang-cc --emit-llvm -o %t %s &&
|
||||
// RUN: grep "i8 52" %t | count 1
|
||||
// RUN: clang-cc -triple=i686-apple-darwin9 --emit-llvm -o - %s | FileCheck %s
|
||||
|
||||
struct et7 {
|
||||
float lv7[0];
|
||||
@@ -9,3 +8,5 @@ struct et7 {
|
||||
52,
|
||||
};
|
||||
|
||||
// CHECK: @yv7 = global
|
||||
// CHECK: i8 52,
|
||||
@@ -1,13 +1,15 @@
|
||||
// RUN: clang-cc -fblocks -triple x86_64-apple-darwin10 -emit-llvm -o %t %s &&
|
||||
// RUN: grep '%call = call i32 (...)\* @rhs()' %t | count 1 &&
|
||||
// If this fails, see about sliding %4, %5, %6 and %7...
|
||||
// RUN: grep '%forwarding1 = getelementptr inbounds %0\* %i, i32 0, i32 1' %t | count 1 &&
|
||||
// RUN: grep '%4 = bitcast i8\*\* %forwarding1 to %0\*\*' %t | count 1 &&
|
||||
// RUN: grep '%5 = load %0\*\* %4' %t | count 1 &&
|
||||
// RUN: grep '%call2 = call i32 (...)\* @rhs()' %t | count 1 &&
|
||||
// RUN: grep '%forwarding3 = getelementptr inbounds %0\* %i, i32 0, i32 1' %t | count 1 &&
|
||||
// RUN: grep '%6 = bitcast i8\*\* %forwarding3 to %0\*\*' %t | count 1 &&
|
||||
// RUN: grep '%7 = load %0\*\* %6' %t | count 1
|
||||
// FIXME: We forcibly strip the names so that the test doesn't vary between
|
||||
// builds with and without asserts. We need a better solution for this.
|
||||
|
||||
// RUN: clang-cc -fblocks -triple x86_64-apple-darwin10 -emit-llvm-bc -o - %s | opt -strip | llvm-dis > %t &&
|
||||
// RUN: grep '%7 = call i32 (...)\* @rhs()' %t | count 1 &&
|
||||
// RUN: grep '%8 = getelementptr inbounds %0\* %1, i32 0, i32 1' %t | count 1 &&
|
||||
// RUN: grep '%9 = bitcast i8\*\* %8 to %0\*\*' %t | count 1 &&
|
||||
// RUN: grep '%10 = load %0\*\* %9' %t | count 1 &&
|
||||
// RUN: grep '%12 = call i32 (...)\* @rhs()' %t | count 1 &&
|
||||
// RUN: grep '%13 = getelementptr inbounds %0\* %1, i32 0, i32 1' %t | count 1 &&
|
||||
// RUN: grep '%14 = bitcast i8\*\* %13 to %0\*\*' %t | count 1 &&
|
||||
// RUN: grep '%15 = load %0\*\* %14' %t | count 1
|
||||
|
||||
int rhs();
|
||||
|
||||
|
||||
16
clang/test/CodeGen/packed-union.c
Normal file
16
clang/test/CodeGen/packed-union.c
Normal file
@@ -0,0 +1,16 @@
|
||||
// RUN: clang-cc -triple x86_64-apple-darwin10 -emit-llvm %s -o %t &&
|
||||
|
||||
// RUN: grep "struct._attrs = type <{ i32, i8 }>" %t &&
|
||||
typedef struct _attrs {
|
||||
unsigned file_attributes;
|
||||
unsigned char filename_length;
|
||||
} __attribute__((__packed__)) attrs;
|
||||
|
||||
// RUN: grep "union._attr_union = type <{ i32, i8 }>" %t
|
||||
typedef union _attr_union {
|
||||
attrs file_attrs;
|
||||
unsigned owner_id;
|
||||
} __attribute__((__packed__)) attr_union;
|
||||
|
||||
attr_union u;
|
||||
|
||||
19
clang/test/CodeGen/pragma-pack-3.c
Normal file
19
clang/test/CodeGen/pragma-pack-3.c
Normal file
@@ -0,0 +1,19 @@
|
||||
// RUN: clang-cc -triple i386-apple-darwin9 %s -emit-llvm -o - | FileCheck -check-prefix X32 %s &&
|
||||
// CHECK-X32: %struct.menu = type <{ i8*, i8, i8 }>
|
||||
// CHECK-X32: %union.command = type <{ i8*, [2 x i8] }>
|
||||
|
||||
// RUN: clang-cc -triple x86_64-apple-darwin9 %s -emit-llvm -o - | FileCheck -check-prefix X64 %s
|
||||
// CHECK-X64: %struct.menu = type <{ i8*, i8, i8 }>
|
||||
// CHECK-X64: %union.command = type <{ i8*, [2 x i8] }>
|
||||
|
||||
// <rdar://problem/7184250>
|
||||
#pragma pack(push, 2)
|
||||
typedef union command {
|
||||
void *windowRef;
|
||||
struct menu {
|
||||
void *menuRef;
|
||||
unsigned char menuItemIndex;
|
||||
} menu;
|
||||
} command;
|
||||
|
||||
command c;
|
||||
@@ -1,37 +1,53 @@
|
||||
// RUN: clang-cc -emit-llvm -o %t %s &&
|
||||
// RUN: clang-cc -emit-llvm %s -o - -verify | FileCheck %s
|
||||
|
||||
// CHECK: @weakvar = weak global
|
||||
// CHECK: @__weakvar_alias = common global
|
||||
// CHECK: @correct_linkage = weak global
|
||||
|
||||
|
||||
// CHECK: @both = alias void ()* @__both
|
||||
// CHECK: @both2 = alias void ()* @__both2
|
||||
// CHECK: @both3 = alias weak void ()* @__both3
|
||||
// CHECK: @a3 = alias weak void ()* @__a3
|
||||
// CHECK: @weakvar_alias = alias weak i32* @__weakvar_alias
|
||||
// CHECK: @foo = alias weak void ()* @__foo
|
||||
// CHECK: @foo2 = alias weak void ()* @__foo2
|
||||
// CHECK: @stutter = alias weak void ()* @__stutter
|
||||
// CHECK: @stutter2 = alias weak void ()* @__stutter2
|
||||
// CHECK: @declfirst = alias weak void ()* @__declfirst
|
||||
// CHECK: @declfirstattr = alias weak void ()* @__declfirstattr
|
||||
// CHECK: @mix2 = alias weak void ()* @__mix2
|
||||
// CHECK: @a1 = alias weak void ()* @__a1
|
||||
// CHECK: @xxx = alias weak void ()* @__xxx
|
||||
|
||||
|
||||
|
||||
// CHECK: define weak void @weakdef()
|
||||
|
||||
|
||||
#pragma weak weakvar
|
||||
int weakvar;
|
||||
// RUN: grep '@weakvar = weak global' %t | count 1 &&
|
||||
|
||||
#pragma weak weakdef
|
||||
void weakdef(void) {}
|
||||
// RUN: grep 'define weak void @weakdef()' %t | count 1 &&
|
||||
|
||||
#pragma weak param // expected-warning {{weak identifier 'param' never declared}}
|
||||
#pragma weak correct_linkage
|
||||
void f(int param) {
|
||||
int correct_linkage;
|
||||
}
|
||||
int correct_linkage;
|
||||
// RUN: grep '@correct_linkage = weak global' %t | count 1 &&
|
||||
|
||||
#pragma weak weakvar_alias = __weakvar_alias
|
||||
int __weakvar_alias;
|
||||
// RUN: grep '@__weakvar_alias = common global' %t | count 1 &&
|
||||
// RUN: grep '@weakvar_alias = alias weak i32\* @__weakvar_alias' %t | count 1 &&
|
||||
//@weakvar_alias = alias weak i32* @__weakvar_alias
|
||||
|
||||
#pragma weak foo = __foo
|
||||
void __foo(void) {}
|
||||
// RUN: grep '@foo = alias weak void ()\* @__foo\>' %t | count 1 &&
|
||||
// RUN: grep 'define void @__foo()' %t | count 1 &&
|
||||
// CHECK: define void @__foo()
|
||||
|
||||
|
||||
void __foo2(void) {}
|
||||
#pragma weak foo2 = __foo2
|
||||
// RUN: grep '@foo2 = alias weak void ()\* @__foo2\>' %t | count 1 &&
|
||||
// RUN: grep 'define void @__foo2()' %t | count 1 &&
|
||||
// CHECK: define void @__foo2()
|
||||
|
||||
|
||||
///// test errors
|
||||
@@ -53,14 +69,12 @@ typedef int __td2;
|
||||
#pragma weak stutter = __stutter
|
||||
#pragma weak stutter = __stutter
|
||||
void __stutter(void) {}
|
||||
// RUN: grep '@stutter = alias weak void ()\* @__stutter\>' %t | count 1 &&
|
||||
// RUN: grep 'define void @__stutter()' %t | count 1 &&
|
||||
// CHECK: define void @__stutter()
|
||||
|
||||
void __stutter2(void) {}
|
||||
#pragma weak stutter2 = __stutter2
|
||||
#pragma weak stutter2 = __stutter2
|
||||
// RUN: grep '@stutter2 = alias weak void ()\* @__stutter2\>' %t | count 1 &&
|
||||
// RUN: grep 'define void @__stutter2()' %t | count 1 &&
|
||||
// CHECK: define void @__stutter2()
|
||||
|
||||
|
||||
// test decl/pragma weak order
|
||||
@@ -68,14 +82,12 @@ void __stutter2(void) {}
|
||||
void __declfirst(void);
|
||||
#pragma weak declfirst = __declfirst
|
||||
void __declfirst(void) {}
|
||||
// RUN: grep '@declfirst = alias weak void ()\* @__declfirst\>' %t | count 1 &&
|
||||
// RUN: grep 'define void @__declfirst()' %t | count 1 &&
|
||||
// CHECK: define void @__declfirst()
|
||||
|
||||
void __declfirstattr(void) __attribute((noinline));
|
||||
#pragma weak declfirstattr = __declfirstattr
|
||||
void __declfirstattr(void) {}
|
||||
// RUN: grep '@declfirstattr = alias weak void ()\* @__declfirstattr\>' %t | count 1 &&
|
||||
// RUN: grep 'define void @__declfirstattr()' %t | count 1 &&
|
||||
// CHECK: define void @__declfirstattr()
|
||||
|
||||
//// test that other attributes are preserved
|
||||
|
||||
@@ -84,7 +96,7 @@ void __declfirstattr(void) {}
|
||||
void mix(void);
|
||||
#pragma weak mix
|
||||
__attribute((weak)) void mix(void) { }
|
||||
// RUN: grep 'define weak void @mix()' %t | count 1 &&
|
||||
// CHECK: define weak void @mix()
|
||||
|
||||
// ensure following __attributes are preserved and that only a single
|
||||
// alias is generated
|
||||
@@ -92,8 +104,7 @@ __attribute((weak)) void mix(void) { }
|
||||
void __mix2(void) __attribute((noinline));
|
||||
void __mix2(void) __attribute((noinline));
|
||||
void __mix2(void) {}
|
||||
// RUN: grep '@mix2 = alias weak void ()\* @__mix2\>' %t | count 1 &&
|
||||
// RUN: grep 'define void @__mix2()' %t | count 1 &&
|
||||
// CHECK: define void @__mix2()
|
||||
|
||||
////////////// test #pragma weak/__attribute combinations
|
||||
|
||||
@@ -102,8 +113,7 @@ void __mix2(void) {}
|
||||
void both(void) __attribute((alias("__both")));
|
||||
#pragma weak both = __both
|
||||
void __both(void) {}
|
||||
// RUN: grep '@both = alias void ()\* @__both\>' %t | count 1 &&
|
||||
// RUN: grep 'define void @__both()' %t | count 1 &&
|
||||
// CHECK: define void @__both()
|
||||
|
||||
// if the TARGET is previously declared then whichever aliasing method
|
||||
// comes first applies and subsequent aliases are discarded.
|
||||
@@ -113,23 +123,20 @@ void __both2(void);
|
||||
void both2(void) __attribute((alias("__both2"))); // first, wins
|
||||
#pragma weak both2 = __both2
|
||||
void __both2(void) {}
|
||||
// RUN: grep '@both2 = alias void ()\* @__both2\>' %t | count 1 &&
|
||||
// RUN: grep 'define void @__both2()' %t | count 1 &&
|
||||
// CHECK: define void @__both2()
|
||||
|
||||
void __both3(void);
|
||||
#pragma weak both3 = __both3 // first, wins
|
||||
void both3(void) __attribute((alias("__both3")));
|
||||
void __both3(void) {}
|
||||
// RUN: grep '@both3 = alias weak void ()\* @__both3\>' %t | count 1 &&
|
||||
// RUN: grep 'define void @__both3()' %t | count 1 &&
|
||||
// CHECK: define void @__both3()
|
||||
|
||||
///////////// ensure that #pragma weak does not alter existing __attributes()
|
||||
|
||||
void __a1(void) __attribute((noinline));
|
||||
#pragma weak a1 = __a1
|
||||
void __a1(void) {}
|
||||
// RUN: grep '@a1 = alias weak void ()\* @__a1\>' %t | count 1 &&
|
||||
// RUN: grep 'define void @__a1()' %t | count 1 &&
|
||||
// CHECK: define void @__a1()
|
||||
|
||||
// attributes introduced BEFORE a combination of #pragma weak and alias()
|
||||
// hold...
|
||||
@@ -137,13 +144,11 @@ void __a3(void) __attribute((noinline));
|
||||
#pragma weak a3 = __a3
|
||||
void a3(void) __attribute((alias("__a3")));
|
||||
void __a3(void) {}
|
||||
// RUN: grep '@a3 = alias weak void ()\* @__a3\>' %t | count 1 &&
|
||||
// RUN: grep 'define void @__a3()' %t | count 1 &&
|
||||
// CHECK: define void @__a3()
|
||||
|
||||
#pragma weak xxx = __xxx
|
||||
__attribute((pure,noinline,const,fastcall)) void __xxx(void) { }
|
||||
// RUN: grep '@xxx = alias weak void ()\* @__xxx\>' %t | count 1 &&
|
||||
// RUN: grep 'define .*fastcall.* void @__xxx()' %t | count 1 &&
|
||||
// CHECK: void @__xxx()
|
||||
|
||||
/// TODO: stuff that still doesn't work
|
||||
|
||||
@@ -155,4 +160,6 @@ void yyy(void){}
|
||||
void zzz(void){}
|
||||
#pragma weak yyy
|
||||
// NOTE: weak doesn't apply, not before or in same TopLevelDec(!)
|
||||
// RUN: grep 'define void @yyy()' %t | count 1
|
||||
// CHECK: define void @yyy()
|
||||
|
||||
int correct_linkage;
|
||||
|
||||
@@ -72,8 +72,9 @@ void f12_1(struct s12 a0) {}
|
||||
// RUN: grep 'define void @f13(.struct.s13_0. noalias sret .agg.result, i32 .a, i32 .b, i32 .c, i32 .d, .struct.s13_1. byval .e, i32 .f)' %t &&
|
||||
|
||||
struct s13_0 { long long f0[3]; };
|
||||
struct s13_1 { long long f0[2]; };
|
||||
struct s13_0 f13(int a, int b, int c, int d,
|
||||
struct s13_1 { long long f0[2]; } e, int f) { while (1) {} }
|
||||
struct s13_1 e, int f) { while (1) {} }
|
||||
|
||||
// RUN: grep 'define void @f14(.*, i8 signext .X)' %t &&
|
||||
void f14(int a, int b, int c, int d, int e, int f,
|
||||
@@ -89,9 +90,10 @@ void f17(float a, float b, float c, float d, float e, float f, float g, float h,
|
||||
long double X) {}
|
||||
|
||||
// Check for valid coercion.
|
||||
// RUN: grep '.1 = bitcast i64. .tmp to .struct.f18_s0.' %t &&
|
||||
// RUN: grep '.2 = load .struct.f18_s0. .1, align 1' %t &&
|
||||
// RUN: grep 'store .struct.f18_s0 .2, .struct.f18_s0. .f18_arg1' %t &&
|
||||
void f18(int a, struct f18_s0 { int f0; } f18_arg1) { while (1) {} }
|
||||
// RUN: grep '.. = bitcast i64. .* to .struct.f18_s0.' %t &&
|
||||
// RUN: grep '.. = load .struct.f18_s0. .., align 1' %t &&
|
||||
// RUN: grep 'store .struct.f18_s0 .., .struct.f18_s0. .f18_arg1' %t &&
|
||||
struct f18_s0 { int f0; };
|
||||
void f18(int a, struct f18_s0 f18_arg1) { while (1) {} }
|
||||
|
||||
// RUN: true
|
||||
|
||||
@@ -14,7 +14,7 @@ int A::* aa[2];
|
||||
int A::* aaa[2][2];
|
||||
|
||||
void f() {
|
||||
// RUN: grep "%.obool = icmp ne i64 %.mp, -1" %t
|
||||
// RUN: grep "%.* = icmp ne i64 %.*, -1" %t
|
||||
if (a) { }
|
||||
|
||||
// FIXME: This doesn't yet work
|
||||
|
||||
@@ -8,8 +8,7 @@ int test(char *C) { // nothing here should warn.
|
||||
return C != 0;
|
||||
}
|
||||
|
||||
int equal(char *a, const char *b)
|
||||
{
|
||||
int equal(char *a, const char *b) {
|
||||
return a == b;
|
||||
}
|
||||
|
||||
@@ -18,21 +17,18 @@ int arrays(char (*a)[5], char(*b)[10], char(*c)[5]) {
|
||||
return a == b; // expected-warning {{comparison of distinct pointer types}}
|
||||
}
|
||||
|
||||
int pointers(int *a)
|
||||
{
|
||||
return a > 0; // expected-warning {{ordered comparison between pointer and integer}}
|
||||
int pointers(int *a) {
|
||||
return a > 0; // no warning. rdar://7163039
|
||||
return a > (void *)0; // expected-warning {{comparison of distinct pointer types}}
|
||||
}
|
||||
|
||||
int function_pointers(int (*a)(int), int (*b)(int))
|
||||
{
|
||||
int function_pointers(int (*a)(int), int (*b)(int)) {
|
||||
return a > b; // expected-warning {{ordered comparison of function pointers}}
|
||||
return function_pointers > function_pointers; // expected-warning {{ordered comparison of function pointers}}
|
||||
return a == (void *) 0;
|
||||
return a == (void *) 1; // expected-warning {{comparison of distinct pointer types}}
|
||||
}
|
||||
|
||||
int void_pointers(void *foo)
|
||||
{
|
||||
int void_pointers(void *foo) {
|
||||
return foo == NULL;
|
||||
}
|
||||
|
||||
27
clang/test/SemaObjC/conditional-expr-5.m
Normal file
27
clang/test/SemaObjC/conditional-expr-5.m
Normal file
@@ -0,0 +1,27 @@
|
||||
// RUN: clang-cc -fsyntax-only -verify %s
|
||||
|
||||
@interface PBXBuildSettingsDictionary
|
||||
{
|
||||
int i;
|
||||
}
|
||||
@end
|
||||
|
||||
@interface XCConditionalBuildSettingsDictionary : PBXBuildSettingsDictionary
|
||||
{
|
||||
}
|
||||
@end
|
||||
|
||||
@implementation PBXBuildSettingsDictionary
|
||||
|
||||
- (XCConditionalBuildSettingsDictionary *)conditionalDictionaryForConditionSet
|
||||
{
|
||||
return i ? self : (id)0;
|
||||
}
|
||||
|
||||
- (XCConditionalBuildSettingsDictionary *)conditionalDictionaryForConditionSet2
|
||||
{
|
||||
return i ? (id)0 : self;
|
||||
}
|
||||
@end
|
||||
|
||||
|
||||
@@ -8,6 +8,19 @@
|
||||
|
||||
@end
|
||||
|
||||
@interface I
|
||||
- (id) compare: (char) arg1;
|
||||
@end
|
||||
|
||||
@interface J
|
||||
- (id) compare: (id) arg1;
|
||||
@end
|
||||
|
||||
SEL foo()
|
||||
{
|
||||
return @selector(compare:); // Non warning on multiple selector found.
|
||||
}
|
||||
|
||||
int main() {
|
||||
SEL s = @selector(retain);
|
||||
SEL s1 = @selector(meth1:);
|
||||
|
||||
@@ -1,61 +0,0 @@
|
||||
/*
|
||||
* Block.h
|
||||
*
|
||||
* Copyright 2008-2009 Apple, Inc. Permission is hereby granted, free of charge,
|
||||
* to any person obtaining a copy of this software and associated documentation
|
||||
* files (the "Software"), to deal in the Software without restriction,
|
||||
* including without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to permit
|
||||
* persons to whom the Software is furnished to do so, subject to the following
|
||||
* conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _Block_H_
|
||||
#define _Block_H_
|
||||
|
||||
#if !defined(BLOCK_EXPORT)
|
||||
# if defined(__cplusplus)
|
||||
# define BLOCK_EXPORT extern "C"
|
||||
# else
|
||||
# define BLOCK_EXPORT extern
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#include <AvailabilityMacros.h>
|
||||
#include <TargetConditionals.h>
|
||||
|
||||
#if __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// Create a heap based copy of a Block or simply add a reference to an existing one.
|
||||
// This must be paired with Block_release to recover memory, even when running
|
||||
// under Objective-C Garbage Collection.
|
||||
BLOCK_EXPORT void *_Block_copy(const void *aBlock);
|
||||
|
||||
// Lose the reference, and if heap based and last reference, recover the memory
|
||||
BLOCK_EXPORT void _Block_release(const void *aBlock);
|
||||
|
||||
#if __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
// Type correct macros
|
||||
|
||||
#define Block_copy(...) ((__typeof(__VA_ARGS__))_Block_copy((const void *)(__VA_ARGS__)))
|
||||
#define Block_release(...) _Block_release((const void *)(__VA_ARGS__))
|
||||
|
||||
|
||||
#endif
|
||||
@@ -1,174 +0,0 @@
|
||||
/*
|
||||
* Block_private.h
|
||||
*
|
||||
* Copyright 2008-2009 Apple, Inc. Permission is hereby granted, free of charge,
|
||||
* to any person obtaining a copy of this software and associated documentation
|
||||
* files (the "Software"), to deal in the Software without restriction,
|
||||
* including without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to permit
|
||||
* persons to whom the Software is furnished to do so, subject to the following
|
||||
* conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _BLOCK_PRIVATE_H_
|
||||
#define _BLOCK_PRIVATE_H_
|
||||
|
||||
#if !defined(BLOCK_EXPORT)
|
||||
# if defined(__cplusplus)
|
||||
# define BLOCK_EXPORT extern "C"
|
||||
# else
|
||||
# define BLOCK_EXPORT extern
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#include <AvailabilityMacros.h>
|
||||
#include <TargetConditionals.h>
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
#if __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
enum {
|
||||
BLOCK_REFCOUNT_MASK = (0xffff),
|
||||
BLOCK_NEEDS_FREE = (1 << 24),
|
||||
BLOCK_HAS_COPY_DISPOSE = (1 << 25),
|
||||
BLOCK_HAS_CTOR = (1 << 26), /* helpers have C++ code */
|
||||
BLOCK_IS_GC = (1 << 27),
|
||||
BLOCK_IS_GLOBAL = (1 << 28),
|
||||
BLOCK_HAS_DESCRIPTOR = (1 << 29),
|
||||
};
|
||||
|
||||
/* revised new layout */
|
||||
struct Block_descriptor {
|
||||
unsigned long int reserved;
|
||||
unsigned long int size;
|
||||
void (*copy)(void *dst, void *src);
|
||||
void (*dispose)(void *);
|
||||
};
|
||||
|
||||
struct Block_layout {
|
||||
void *isa;
|
||||
int flags;
|
||||
int reserved;
|
||||
void (*invoke)(void *, ...);
|
||||
struct Block_descriptor *descriptor;
|
||||
/* imported variables */
|
||||
};
|
||||
|
||||
|
||||
|
||||
struct Block_byref {
|
||||
void *isa;
|
||||
struct Block_byref *forwarding;
|
||||
int flags; /* refcount; */
|
||||
int size;
|
||||
void (*byref_keep)(struct Block_byref *dst, struct Block_byref *src);
|
||||
void (*byref_destroy)(struct Block_byref *);
|
||||
/* long shared[0]; */
|
||||
};
|
||||
|
||||
struct Block_byref_header {
|
||||
void *isa;
|
||||
struct Block_byref *forwarding;
|
||||
int flags;
|
||||
int size;
|
||||
};
|
||||
|
||||
|
||||
/* Runtime support functions used by compiler when generating copy/dispose helpers */
|
||||
|
||||
enum {
|
||||
/* see function implementation for a more complete description of these fields and combinations */
|
||||
BLOCK_FIELD_IS_OBJECT = 3, /* id, NSObject, __attribute__((NSObject)), block, ... */
|
||||
BLOCK_FIELD_IS_BLOCK = 7, /* a block variable */
|
||||
BLOCK_FIELD_IS_BYREF = 8, /* the on stack structure holding the __block variable */
|
||||
BLOCK_FIELD_IS_WEAK = 16, /* declared __weak, only used in byref copy helpers */
|
||||
BLOCK_BYREF_CALLER = 128, /* called from __block (byref) copy/dispose support routines. */
|
||||
};
|
||||
|
||||
/* Runtime entry point called by compiler when assigning objects inside copy helper routines */
|
||||
BLOCK_EXPORT void _Block_object_assign(void *destAddr, const void *object, const int flags);
|
||||
/* BLOCK_FIELD_IS_BYREF is only used from within block copy helpers */
|
||||
|
||||
|
||||
/* runtime entry point called by the compiler when disposing of objects inside dispose helper routine */
|
||||
BLOCK_EXPORT void _Block_object_dispose(const void *object, const int flags);
|
||||
|
||||
|
||||
|
||||
/* Other support functions */
|
||||
|
||||
/* runtime entry to get total size of a closure */
|
||||
BLOCK_EXPORT unsigned long int Block_size(void *block_basic);
|
||||
|
||||
|
||||
|
||||
/* the raw data space for runtime classes for blocks */
|
||||
/* class+meta used for stack, malloc, and collectable based blocks */
|
||||
BLOCK_EXPORT void * _NSConcreteStackBlock[32];
|
||||
BLOCK_EXPORT void * _NSConcreteMallocBlock[32];
|
||||
BLOCK_EXPORT void * _NSConcreteAutoBlock[32];
|
||||
BLOCK_EXPORT void * _NSConcreteFinalizingBlock[32];
|
||||
BLOCK_EXPORT void * _NSConcreteGlobalBlock[32];
|
||||
BLOCK_EXPORT void * _NSConcreteWeakBlockVariable[32];
|
||||
|
||||
|
||||
/* the intercept routines that must be used under GC */
|
||||
BLOCK_EXPORT void _Block_use_GC( void *(*alloc)(const unsigned long, const bool isOne, const bool isObject),
|
||||
void (*setHasRefcount)(const void *, const bool),
|
||||
void (*gc_assign_strong)(void *, void **),
|
||||
void (*gc_assign_weak)(const void *, void *),
|
||||
void (*gc_memmove)(void *, void *, unsigned long));
|
||||
|
||||
/* earlier version, now simply transitional */
|
||||
BLOCK_EXPORT void _Block_use_GC5( void *(*alloc)(const unsigned long, const bool isOne, const bool isObject),
|
||||
void (*setHasRefcount)(const void *, const bool),
|
||||
void (*gc_assign_strong)(void *, void **),
|
||||
void (*gc_assign_weak)(const void *, void *));
|
||||
|
||||
BLOCK_EXPORT void _Block_use_RR( void (*retain)(const void *),
|
||||
void (*release)(const void *));
|
||||
|
||||
/* make a collectable GC heap based Block. Not useful under non-GC. */
|
||||
BLOCK_EXPORT void *_Block_copy_collectable(const void *aBlock);
|
||||
|
||||
/* thread-unsafe diagnostic */
|
||||
BLOCK_EXPORT const char *_Block_dump(const void *block);
|
||||
|
||||
|
||||
/* Obsolete */
|
||||
|
||||
/* first layout */
|
||||
struct Block_basic {
|
||||
void *isa;
|
||||
int Block_flags; /* int32_t */
|
||||
int Block_size; /* XXX should be packed into Block_flags */
|
||||
void (*Block_invoke)(void *);
|
||||
void (*Block_copy)(void *dst, void *src); /* iff BLOCK_HAS_COPY_DISPOSE */
|
||||
void (*Block_dispose)(void *); /* iff BLOCK_HAS_COPY_DISPOSE */
|
||||
/* long params[0]; // where const imports, __block storage references, etc. get laid down */
|
||||
};
|
||||
|
||||
|
||||
#if __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#endif
|
||||
@@ -1,8 +0,0 @@
|
||||
PROJECT( BlocksRuntime )
|
||||
|
||||
SET( SRCS
|
||||
runtime.c
|
||||
data.c
|
||||
)
|
||||
|
||||
ADD_LIBRARY( ${PROJECT_NAME} SHARED ${SRCS})
|
||||
@@ -1,41 +0,0 @@
|
||||
/*
|
||||
* data.c
|
||||
*
|
||||
* Copyright 2008-2009 Apple, Inc. Permission is hereby granted, free of charge,
|
||||
* to any person obtaining a copy of this software and associated documentation
|
||||
* files (the "Software"), to deal in the Software without restriction,
|
||||
* including without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to permit
|
||||
* persons to whom the Software is furnished to do so, subject to the following
|
||||
* conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*
|
||||
*/
|
||||
|
||||
/********************
|
||||
NSBlock support
|
||||
|
||||
We allocate space and export a symbol to be used as the Class for the on-stack and malloc'ed copies until ObjC arrives on the scene. These data areas are set up by Foundation to link in as real classes post facto.
|
||||
|
||||
We keep these in a separate file so that we can include the runtime code in test subprojects but not include the data so that compiled code that sees the data in libSystem doesn't get confused by a second copy. Somehow these don't get unified in a common block.
|
||||
**********************/
|
||||
|
||||
void * _NSConcreteStackBlock[32] = { 0 };
|
||||
void * _NSConcreteMallocBlock[32] = { 0 };
|
||||
void * _NSConcreteAutoBlock[32] = { 0 };
|
||||
void * _NSConcreteFinalizingBlock[32] = { 0 };
|
||||
void * _NSConcreteGlobalBlock[32] = { 0 };
|
||||
void * _NSConcreteWeakBlockVariable[32] = { 0 };
|
||||
|
||||
void _Block_copy_error(void) {
|
||||
}
|
||||
@@ -1,668 +0,0 @@
|
||||
/*
|
||||
* runtime.c
|
||||
*
|
||||
* Copyright 2008-2009 Apple, Inc. Permission is hereby granted, free of charge,
|
||||
* to any person obtaining a copy of this software and associated documentation
|
||||
* files (the "Software"), to deal in the Software without restriction,
|
||||
* including without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to permit
|
||||
* persons to whom the Software is furnished to do so, subject to the following
|
||||
* conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "Block_private.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#if !TARGET_OS_WIN32
|
||||
#include <libkern/OSAtomic.h>
|
||||
#else
|
||||
#define _CRT_SECURE_NO_WARNINGS 1
|
||||
#include <windows.h>
|
||||
static __inline bool OSAtomicCompareAndSwapLong(long oldl, long newl, long volatile *dst)
|
||||
{
|
||||
// fixme barrier is overkill -- see objc-os.h
|
||||
long original = InterlockedCompareExchange(dst, newl, oldl);
|
||||
return (original == oldl);
|
||||
}
|
||||
|
||||
static __inline bool OSAtomicCompareAndSwapInt(int oldi, int newi, int volatile *dst)
|
||||
{
|
||||
// fixme barrier is overkill -- see objc-os.h
|
||||
int original = InterlockedCompareExchange(dst, newi, oldi);
|
||||
return (original == oldi);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/***********************
|
||||
Globals
|
||||
************************/
|
||||
|
||||
static void *_Block_copy_class = _NSConcreteMallocBlock;
|
||||
static void *_Block_copy_finalizing_class = _NSConcreteMallocBlock;
|
||||
static int _Block_copy_flag = BLOCK_NEEDS_FREE;
|
||||
static int _Byref_flag_initial_value = BLOCK_NEEDS_FREE | 2;
|
||||
|
||||
static const int WANTS_ONE = (1 << 16);
|
||||
|
||||
static bool isGC = false;
|
||||
|
||||
/*******************************************************************************
|
||||
Internal Utilities
|
||||
********************************************************************************/
|
||||
|
||||
#if 0
|
||||
static unsigned long int latching_incr_long(unsigned long int *where) {
|
||||
while (1) {
|
||||
unsigned long int old_value = *(volatile unsigned long int *)where;
|
||||
if ((old_value & BLOCK_REFCOUNT_MASK) == BLOCK_REFCOUNT_MASK) {
|
||||
return BLOCK_REFCOUNT_MASK;
|
||||
}
|
||||
if (OSAtomicCompareAndSwapLong(old_value, old_value+1, (volatile long int *)where)) {
|
||||
return old_value+1;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
static int latching_incr_int(int *where) {
|
||||
while (1) {
|
||||
int old_value = *(volatile int *)where;
|
||||
if ((old_value & BLOCK_REFCOUNT_MASK) == BLOCK_REFCOUNT_MASK) {
|
||||
return BLOCK_REFCOUNT_MASK;
|
||||
}
|
||||
if (OSAtomicCompareAndSwapInt(old_value, old_value+1, (volatile int *)where)) {
|
||||
return old_value+1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#if 0
|
||||
static int latching_decr_long(unsigned long int *where) {
|
||||
while (1) {
|
||||
unsigned long int old_value = *(volatile int *)where;
|
||||
if ((old_value & BLOCK_REFCOUNT_MASK) == BLOCK_REFCOUNT_MASK) {
|
||||
return BLOCK_REFCOUNT_MASK;
|
||||
}
|
||||
if ((old_value & BLOCK_REFCOUNT_MASK) == 0) {
|
||||
return 0;
|
||||
}
|
||||
if (OSAtomicCompareAndSwapLong(old_value, old_value-1, (volatile long int *)where)) {
|
||||
return old_value-1;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
static int latching_decr_int(int *where) {
|
||||
while (1) {
|
||||
int old_value = *(volatile int *)where;
|
||||
if ((old_value & BLOCK_REFCOUNT_MASK) == BLOCK_REFCOUNT_MASK) {
|
||||
return BLOCK_REFCOUNT_MASK;
|
||||
}
|
||||
if ((old_value & BLOCK_REFCOUNT_MASK) == 0) {
|
||||
return 0;
|
||||
}
|
||||
if (OSAtomicCompareAndSwapInt(old_value, old_value-1, (volatile int *)where)) {
|
||||
return old_value-1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/***********************
|
||||
GC support stub routines
|
||||
************************/
|
||||
#if !TARGET_OS_WIN32
|
||||
#pragma mark GC Support Routines
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
static void *_Block_alloc_default(const unsigned long size, const bool initialCountIsOne, const bool isObject) {
|
||||
return malloc(size);
|
||||
}
|
||||
|
||||
static void _Block_assign_default(void *value, void **destptr) {
|
||||
*destptr = value;
|
||||
}
|
||||
|
||||
static void _Block_setHasRefcount_default(const void *ptr, const bool hasRefcount) {
|
||||
}
|
||||
|
||||
static void _Block_do_nothing(const void *aBlock) { }
|
||||
|
||||
static void _Block_retain_object_default(const void *ptr) {
|
||||
if (!ptr) return;
|
||||
}
|
||||
|
||||
static void _Block_release_object_default(const void *ptr) {
|
||||
if (!ptr) return;
|
||||
}
|
||||
|
||||
static void _Block_assign_weak_default(const void *ptr, void *dest) {
|
||||
#if !TARGET_OS_WIN32
|
||||
*(long *)dest = (long)ptr;
|
||||
#else
|
||||
*(void **)dest = (void *)ptr;
|
||||
#endif
|
||||
}
|
||||
|
||||
static void _Block_memmove_default(void *dst, void *src, unsigned long size) {
|
||||
memmove(dst, src, (size_t)size);
|
||||
}
|
||||
|
||||
static void _Block_memmove_gc_broken(void *dest, void *src, unsigned long size) {
|
||||
void **destp = (void **)dest;
|
||||
void **srcp = (void **)src;
|
||||
while (size) {
|
||||
_Block_assign_default(*srcp, destp);
|
||||
destp++;
|
||||
srcp++;
|
||||
size -= sizeof(void *);
|
||||
}
|
||||
}
|
||||
|
||||
/**************************************************************************
|
||||
GC support callout functions - initially set to stub routines
|
||||
***************************************************************************/
|
||||
|
||||
static void *(*_Block_allocator)(const unsigned long, const bool isOne, const bool isObject) = _Block_alloc_default;
|
||||
static void (*_Block_deallocator)(const void *) = (void (*)(const void *))free;
|
||||
static void (*_Block_assign)(void *value, void **destptr) = _Block_assign_default;
|
||||
static void (*_Block_setHasRefcount)(const void *ptr, const bool hasRefcount) = _Block_setHasRefcount_default;
|
||||
static void (*_Block_retain_object)(const void *ptr) = _Block_retain_object_default;
|
||||
static void (*_Block_release_object)(const void *ptr) = _Block_release_object_default;
|
||||
static void (*_Block_assign_weak)(const void *dest, void *ptr) = _Block_assign_weak_default;
|
||||
static void (*_Block_memmove)(void *dest, void *src, unsigned long size) = _Block_memmove_default;
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
GC support SPI functions - called from ObjC runtime and CoreFoundation
|
||||
***************************************************************************/
|
||||
|
||||
// Public SPI
|
||||
// Called from objc-auto to turn on GC.
|
||||
// version 3, 4 arg, but changed 1st arg
|
||||
void _Block_use_GC( void *(*alloc)(const unsigned long, const bool isOne, const bool isObject),
|
||||
void (*setHasRefcount)(const void *, const bool),
|
||||
void (*gc_assign)(void *, void **),
|
||||
void (*gc_assign_weak)(const void *, void *),
|
||||
void (*gc_memmove)(void *, void *, unsigned long)) {
|
||||
|
||||
isGC = true;
|
||||
_Block_allocator = alloc;
|
||||
_Block_deallocator = _Block_do_nothing;
|
||||
_Block_assign = gc_assign;
|
||||
_Block_copy_flag = BLOCK_IS_GC;
|
||||
_Block_copy_class = _NSConcreteAutoBlock;
|
||||
// blocks with ctors & dtors need to have the dtor run from a class with a finalizer
|
||||
_Block_copy_finalizing_class = _NSConcreteFinalizingBlock;
|
||||
_Block_setHasRefcount = setHasRefcount;
|
||||
_Byref_flag_initial_value = BLOCK_IS_GC; // no refcount
|
||||
_Block_retain_object = _Block_do_nothing;
|
||||
_Block_release_object = _Block_do_nothing;
|
||||
_Block_assign_weak = gc_assign_weak;
|
||||
_Block_memmove = gc_memmove;
|
||||
}
|
||||
|
||||
// transitional
|
||||
void _Block_use_GC5( void *(*alloc)(const unsigned long, const bool isOne, const bool isObject),
|
||||
void (*setHasRefcount)(const void *, const bool),
|
||||
void (*gc_assign)(void *, void **),
|
||||
void (*gc_assign_weak)(const void *, void *)) {
|
||||
// until objc calls _Block_use_GC it will call us; supply a broken internal memmove implementation until then
|
||||
_Block_use_GC(alloc, setHasRefcount, gc_assign, gc_assign_weak, _Block_memmove_gc_broken);
|
||||
}
|
||||
|
||||
|
||||
// Called from objc-auto to alternatively turn on retain/release.
|
||||
// Prior to this the only "object" support we can provide is for those
|
||||
// super special objects that live in libSystem, namely dispatch queues.
|
||||
// Blocks and Block_byrefs have their own special entry points.
|
||||
void _Block_use_RR( void (*retain)(const void *),
|
||||
void (*release)(const void *)) {
|
||||
_Block_retain_object = retain;
|
||||
_Block_release_object = release;
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
Internal Support routines for copying
|
||||
********************************************************************************/
|
||||
|
||||
#if !TARGET_OS_WIN32
|
||||
#pragma mark Copy/Release support
|
||||
#endif
|
||||
|
||||
// Copy, or bump refcount, of a block. If really copying, call the copy helper if present.
|
||||
static void *_Block_copy_internal(const void *arg, const int flags) {
|
||||
struct Block_layout *aBlock;
|
||||
const bool wantsOne = (WANTS_ONE & flags) == WANTS_ONE;
|
||||
|
||||
//printf("_Block_copy_internal(%p, %x)\n", arg, flags);
|
||||
if (!arg) return NULL;
|
||||
|
||||
|
||||
// The following would be better done as a switch statement
|
||||
aBlock = (struct Block_layout *)arg;
|
||||
if (aBlock->flags & BLOCK_NEEDS_FREE) {
|
||||
// latches on high
|
||||
latching_incr_int(&aBlock->flags);
|
||||
return aBlock;
|
||||
}
|
||||
else if (aBlock->flags & BLOCK_IS_GC) {
|
||||
// GC refcounting is expensive so do most refcounting here.
|
||||
if (wantsOne && ((latching_incr_int(&aBlock->flags) & BLOCK_REFCOUNT_MASK) == 1)) {
|
||||
// Tell collector to hang on this - it will bump the GC refcount version
|
||||
_Block_setHasRefcount(aBlock, true);
|
||||
}
|
||||
return aBlock;
|
||||
}
|
||||
else if (aBlock->flags & BLOCK_IS_GLOBAL) {
|
||||
return aBlock;
|
||||
}
|
||||
|
||||
// Its a stack block. Make a copy.
|
||||
if (!isGC) {
|
||||
struct Block_layout *result = malloc(aBlock->descriptor->size);
|
||||
if (!result) return (void *)0;
|
||||
memmove(result, aBlock, aBlock->descriptor->size); // bitcopy first
|
||||
// reset refcount
|
||||
result->flags &= ~(BLOCK_REFCOUNT_MASK); // XXX not needed
|
||||
result->flags |= BLOCK_NEEDS_FREE | 1;
|
||||
result->isa = _NSConcreteMallocBlock;
|
||||
if (result->flags & BLOCK_HAS_COPY_DISPOSE) {
|
||||
//printf("calling block copy helper %p(%p, %p)...\n", aBlock->descriptor->copy, result, aBlock);
|
||||
(*aBlock->descriptor->copy)(result, aBlock); // do fixup
|
||||
}
|
||||
return result;
|
||||
}
|
||||
else {
|
||||
// Under GC want allocation with refcount 1 so we ask for "true" if wantsOne
|
||||
// This allows the copy helper routines to make non-refcounted block copies under GC
|
||||
unsigned long int flags = aBlock->flags;
|
||||
bool hasCTOR = (flags & BLOCK_HAS_CTOR) != 0;
|
||||
struct Block_layout *result = _Block_allocator(aBlock->descriptor->size, wantsOne, hasCTOR);
|
||||
if (!result) return (void *)0;
|
||||
memmove(result, aBlock, aBlock->descriptor->size); // bitcopy first
|
||||
// reset refcount
|
||||
// if we copy a malloc block to a GC block then we need to clear NEEDS_FREE.
|
||||
flags &= ~(BLOCK_NEEDS_FREE|BLOCK_REFCOUNT_MASK); // XXX not needed
|
||||
if (wantsOne)
|
||||
flags |= BLOCK_IS_GC | 1;
|
||||
else
|
||||
flags |= BLOCK_IS_GC;
|
||||
result->flags = flags;
|
||||
if (flags & BLOCK_HAS_COPY_DISPOSE) {
|
||||
//printf("calling block copy helper...\n");
|
||||
(*aBlock->descriptor->copy)(result, aBlock); // do fixup
|
||||
}
|
||||
if (hasCTOR) {
|
||||
result->isa = _NSConcreteFinalizingBlock;
|
||||
}
|
||||
else {
|
||||
result->isa = _NSConcreteAutoBlock;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// Runtime entry points for maintaining the sharing knowledge of byref data blocks.
|
||||
|
||||
// A closure has been copied and its fixup routine is asking us to fix up the reference to the shared byref data
|
||||
// Closures that aren't copied must still work, so everyone always accesses variables after dereferencing the forwarding ptr.
|
||||
// We ask if the byref pointer that we know about has already been copied to the heap, and if so, increment it.
|
||||
// Otherwise we need to copy it and update the stack forwarding pointer
|
||||
// XXX We need to account for weak/nonretained read-write barriers.
|
||||
static void _Block_byref_assign_copy(void *dest, const void *arg, const int flags) {
|
||||
struct Block_byref **destp = (struct Block_byref **)dest;
|
||||
struct Block_byref *src = (struct Block_byref *)arg;
|
||||
|
||||
//printf("_Block_byref_assign_copy called, byref destp %p, src %p, flags %x\n", destp, src, flags);
|
||||
//printf("src dump: %s\n", _Block_byref_dump(src));
|
||||
if (src->forwarding->flags & BLOCK_IS_GC) {
|
||||
; // don't need to do any more work
|
||||
}
|
||||
else if ((src->forwarding->flags & BLOCK_REFCOUNT_MASK) == 0) {
|
||||
//printf("making copy\n");
|
||||
// src points to stack
|
||||
bool isWeak = ((flags & (BLOCK_FIELD_IS_BYREF|BLOCK_FIELD_IS_WEAK)) == (BLOCK_FIELD_IS_BYREF|BLOCK_FIELD_IS_WEAK));
|
||||
// if its weak ask for an object (only matters under GC)
|
||||
struct Block_byref *copy = (struct Block_byref *)_Block_allocator(src->size, false, isWeak);
|
||||
copy->flags = src->flags | _Byref_flag_initial_value; // non-GC one for caller, one for stack
|
||||
copy->forwarding = copy; // patch heap copy to point to itself (skip write-barrier)
|
||||
src->forwarding = copy; // patch stack to point to heap copy
|
||||
copy->size = src->size;
|
||||
if (isWeak) {
|
||||
copy->isa = &_NSConcreteWeakBlockVariable; // mark isa field so it gets weak scanning
|
||||
}
|
||||
if (src->flags & BLOCK_HAS_COPY_DISPOSE) {
|
||||
// Trust copy helper to copy everything of interest
|
||||
// If more than one field shows up in a byref block this is wrong XXX
|
||||
copy->byref_keep = src->byref_keep;
|
||||
copy->byref_destroy = src->byref_destroy;
|
||||
(*src->byref_keep)(copy, src);
|
||||
}
|
||||
else {
|
||||
// just bits. Blast 'em using _Block_memmove in case they're __strong
|
||||
_Block_memmove(
|
||||
(void *)©->byref_keep,
|
||||
(void *)&src->byref_keep,
|
||||
src->size - sizeof(struct Block_byref_header));
|
||||
}
|
||||
}
|
||||
// already copied to heap
|
||||
else if ((src->forwarding->flags & BLOCK_NEEDS_FREE) == BLOCK_NEEDS_FREE) {
|
||||
latching_incr_int(&src->forwarding->flags);
|
||||
}
|
||||
// assign byref data block pointer into new Block
|
||||
_Block_assign(src->forwarding, (void **)destp);
|
||||
}
|
||||
|
||||
// Old compiler SPI
|
||||
static void _Block_byref_release(const void *arg) {
|
||||
struct Block_byref *shared_struct = (struct Block_byref *)arg;
|
||||
int refcount;
|
||||
|
||||
// dereference the forwarding pointer since the compiler isn't doing this anymore (ever?)
|
||||
shared_struct = shared_struct->forwarding;
|
||||
|
||||
//printf("_Block_byref_release %p called, flags are %x\n", shared_struct, shared_struct->flags);
|
||||
// To support C++ destructors under GC we arrange for there to be a finalizer for this
|
||||
// by using an isa that directs the code to a finalizer that calls the byref_destroy method.
|
||||
if ((shared_struct->flags & BLOCK_NEEDS_FREE) == 0) {
|
||||
return; // stack or GC or global
|
||||
}
|
||||
refcount = shared_struct->flags & BLOCK_REFCOUNT_MASK;
|
||||
if (refcount <= 0) {
|
||||
printf("_Block_byref_release: Block byref data structure at %p underflowed\n", arg);
|
||||
}
|
||||
else if ((latching_decr_int(&shared_struct->flags) & BLOCK_REFCOUNT_MASK) == 0) {
|
||||
//printf("disposing of heap based byref block\n");
|
||||
if (shared_struct->flags & BLOCK_HAS_COPY_DISPOSE) {
|
||||
//printf("calling out to helper\n");
|
||||
(*shared_struct->byref_destroy)(shared_struct);
|
||||
}
|
||||
_Block_deallocator((struct Block_layout *)shared_struct);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/************************************************************
|
||||
*
|
||||
* API supporting SPI
|
||||
* _Block_copy, _Block_release, and (old) _Block_destroy
|
||||
*
|
||||
***********************************************************/
|
||||
|
||||
#if !TARGET_OS_WIN32
|
||||
#pragma mark SPI/API
|
||||
#endif
|
||||
|
||||
void *_Block_copy(const void *arg) {
|
||||
return _Block_copy_internal(arg, WANTS_ONE);
|
||||
}
|
||||
|
||||
|
||||
// API entry point to release a copied Block
|
||||
void _Block_release(void *arg) {
|
||||
struct Block_layout *aBlock = (struct Block_layout *)arg;
|
||||
int32_t newCount;
|
||||
if (!aBlock) return;
|
||||
newCount = latching_decr_int(&aBlock->flags) & BLOCK_REFCOUNT_MASK;
|
||||
if (newCount > 0) return;
|
||||
// Hit zero
|
||||
if (aBlock->flags & BLOCK_IS_GC) {
|
||||
// Tell GC we no longer have our own refcounts. GC will decr its refcount
|
||||
// and unless someone has done a CFRetain or marked it uncollectable it will
|
||||
// now be subject to GC reclamation.
|
||||
_Block_setHasRefcount(aBlock, false);
|
||||
}
|
||||
else if (aBlock->flags & BLOCK_NEEDS_FREE) {
|
||||
if (aBlock->flags & BLOCK_HAS_COPY_DISPOSE)(*aBlock->descriptor->dispose)(aBlock);
|
||||
_Block_deallocator(aBlock);
|
||||
}
|
||||
else if (aBlock->flags & BLOCK_IS_GLOBAL) {
|
||||
;
|
||||
}
|
||||
else {
|
||||
printf("Block_release called upon a stack Block: %p, ignored\n", aBlock);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Old Compiler SPI point to release a copied Block used by the compiler in dispose helpers
|
||||
static void _Block_destroy(const void *arg) {
|
||||
struct Block_layout *aBlock;
|
||||
if (!arg) return;
|
||||
aBlock = (struct Block_layout *)arg;
|
||||
if (aBlock->flags & BLOCK_IS_GC) {
|
||||
// assert(aBlock->Block_flags & BLOCK_HAS_CTOR);
|
||||
return; // ignore, we are being called because of a DTOR
|
||||
}
|
||||
_Block_release(aBlock);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/************************************************************
|
||||
*
|
||||
* SPI used by other layers
|
||||
*
|
||||
***********************************************************/
|
||||
|
||||
// SPI, also internal. Called from NSAutoBlock only under GC
|
||||
void *_Block_copy_collectable(const void *aBlock) {
|
||||
return _Block_copy_internal(aBlock, 0);
|
||||
}
|
||||
|
||||
|
||||
// SPI
|
||||
unsigned long int Block_size(void *arg) {
|
||||
return ((struct Block_layout *)arg)->descriptor->size;
|
||||
}
|
||||
|
||||
|
||||
#if !TARGET_OS_WIN32
|
||||
#pragma mark Compiler SPI entry points
|
||||
#endif
|
||||
|
||||
|
||||
/*******************************************************
|
||||
|
||||
Entry points used by the compiler - the real API!
|
||||
|
||||
|
||||
A Block can reference four different kinds of things that require help when the Block is copied to the heap.
|
||||
1) C++ stack based objects
|
||||
2) References to Objective-C objects
|
||||
3) Other Blocks
|
||||
4) __block variables
|
||||
|
||||
In these cases helper functions are synthesized by the compiler for use in Block_copy and Block_release, called the copy and dispose helpers. The copy helper emits a call to the C++ const copy constructor for C++ stack based objects and for the rest calls into the runtime support function _Block_object_assign. The dispose helper has a call to the C++ destructor for case 1 and a call into _Block_object_dispose for the rest.
|
||||
|
||||
The flags parameter of _Block_object_assign and _Block_object_dispose is set to
|
||||
* BLOCK_FIELD_IS_OBJECT (3), for the case of an Objective-C Object,
|
||||
* BLOCK_FIELD_IS_BLOCK (7), for the case of another Block, and
|
||||
* BLOCK_FIELD_IS_BYREF (8), for the case of a __block variable.
|
||||
If the __block variable is marked weak the compiler also or's in BLOCK_FIELD_IS_WEAK (16).
|
||||
|
||||
So the Block copy/dispose helpers should only ever generate the four flag values of 3, 7, 8, and 24.
|
||||
|
||||
When a __block variable is either a C++ object, an Objective-C object, or another Block then the compiler also generates copy/dispose helper functions. Similarly to the Block copy helper, the "__block" copy helper (formerly and still a.k.a. "byref" copy helper) will do a C++ copy constructor (not a const one though!) and the dispose helper will do the destructor. And similarly the helpers will call into the same two support functions with the same values for objects and Blocks with the additional BLOCK_BYREF_CALLER (128) bit of information supplied.
|
||||
|
||||
So the __block copy/dispose helpers will generate flag values of 3 or 7 for objects and Blocks respectively, with BLOCK_FIELD_IS_WEAK (16) or'ed as appropriate and always 128 or'd in, for the following set of possibilities:
|
||||
__block id 128+3
|
||||
__weak block id 128+3+16
|
||||
__block (^Block) 128+7
|
||||
__weak __block (^Block) 128+7+16
|
||||
|
||||
The implementation of the two routines would be improved by switch statements enumerating the eight cases.
|
||||
|
||||
********************************************************/
|
||||
|
||||
//
|
||||
// When Blocks or Block_byrefs hold objects then their copy routine helpers use this entry point
|
||||
// to do the assignment.
|
||||
//
|
||||
void _Block_object_assign(void *destAddr, const void *object, const int flags) {
|
||||
//printf("_Block_object_assign(*%p, %p, %x)\n", destAddr, object, flags);
|
||||
if ((flags & BLOCK_BYREF_CALLER) == BLOCK_BYREF_CALLER) {
|
||||
if ((flags & BLOCK_FIELD_IS_WEAK) == BLOCK_FIELD_IS_WEAK) {
|
||||
_Block_assign_weak(object, destAddr);
|
||||
}
|
||||
else {
|
||||
// do *not* retain or *copy* __block variables whatever they are
|
||||
_Block_assign((void *)object, destAddr);
|
||||
}
|
||||
}
|
||||
else if ((flags & BLOCK_FIELD_IS_BYREF) == BLOCK_FIELD_IS_BYREF) {
|
||||
// copying a __block reference from the stack Block to the heap
|
||||
// flags will indicate if it holds a __weak reference and needs a special isa
|
||||
_Block_byref_assign_copy(destAddr, object, flags);
|
||||
}
|
||||
// (this test must be before next one)
|
||||
else if ((flags & BLOCK_FIELD_IS_BLOCK) == BLOCK_FIELD_IS_BLOCK) {
|
||||
// copying a Block declared variable from the stack Block to the heap
|
||||
_Block_assign(_Block_copy_internal(object, flags), destAddr);
|
||||
}
|
||||
// (this test must be after previous one)
|
||||
else if ((flags & BLOCK_FIELD_IS_OBJECT) == BLOCK_FIELD_IS_OBJECT) {
|
||||
//printf("retaining object at %p\n", object);
|
||||
_Block_retain_object(object);
|
||||
//printf("done retaining object at %p\n", object);
|
||||
_Block_assign((void *)object, destAddr);
|
||||
}
|
||||
}
|
||||
|
||||
// When Blocks or Block_byrefs hold objects their destroy helper routines call this entry point
|
||||
// to help dispose of the contents
|
||||
// Used initially only for __attribute__((NSObject)) marked pointers.
|
||||
void _Block_object_dispose(const void *object, const int flags) {
|
||||
//printf("_Block_object_dispose(%p, %x)\n", object, flags);
|
||||
if (flags & BLOCK_FIELD_IS_BYREF) {
|
||||
// get rid of the __block data structure held in a Block
|
||||
_Block_byref_release(object);
|
||||
}
|
||||
else if ((flags & (BLOCK_FIELD_IS_BLOCK|BLOCK_BYREF_CALLER)) == BLOCK_FIELD_IS_BLOCK) {
|
||||
// get rid of a referenced Block held by this Block
|
||||
// (ignore __block Block variables, compiler doesn't need to call us)
|
||||
_Block_destroy(object);
|
||||
}
|
||||
else if ((flags & (BLOCK_FIELD_IS_WEAK|BLOCK_FIELD_IS_BLOCK|BLOCK_BYREF_CALLER)) == BLOCK_FIELD_IS_OBJECT) {
|
||||
// get rid of a referenced object held by this Block
|
||||
// (ignore __block object variables, compiler doesn't need to call us)
|
||||
_Block_release_object(object);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*******************
|
||||
Debugging support
|
||||
********************/
|
||||
#if !TARGET_OS_WIN32
|
||||
#pragma mark Debugging
|
||||
#endif
|
||||
|
||||
|
||||
const char *_Block_dump(const void *block) {
|
||||
struct Block_layout *closure = (struct Block_layout *)block;
|
||||
static char buffer[512];
|
||||
char *cp = buffer;
|
||||
if (closure == NULL) {
|
||||
sprintf(cp, "NULL passed to _Block_dump\n");
|
||||
return buffer;
|
||||
}
|
||||
if (! (closure->flags & BLOCK_HAS_DESCRIPTOR)) {
|
||||
printf("Block compiled by obsolete compiler, please recompile source for this Block\n");
|
||||
exit(1);
|
||||
}
|
||||
cp += sprintf(cp, "^%p (new layout) =\n", closure);
|
||||
if (closure->isa == NULL) {
|
||||
cp += sprintf(cp, "isa: NULL\n");
|
||||
}
|
||||
else if (closure->isa == _NSConcreteStackBlock) {
|
||||
cp += sprintf(cp, "isa: stack Block\n");
|
||||
}
|
||||
else if (closure->isa == _NSConcreteMallocBlock) {
|
||||
cp += sprintf(cp, "isa: malloc heap Block\n");
|
||||
}
|
||||
else if (closure->isa == _NSConcreteAutoBlock) {
|
||||
cp += sprintf(cp, "isa: GC heap Block\n");
|
||||
}
|
||||
else if (closure->isa == _NSConcreteGlobalBlock) {
|
||||
cp += sprintf(cp, "isa: global Block\n");
|
||||
}
|
||||
else if (closure->isa == _NSConcreteFinalizingBlock) {
|
||||
cp += sprintf(cp, "isa: finalizing Block\n");
|
||||
}
|
||||
else {
|
||||
cp += sprintf(cp, "isa?: %p\n", closure->isa);
|
||||
}
|
||||
cp += sprintf(cp, "flags:");
|
||||
if (closure->flags & BLOCK_HAS_DESCRIPTOR) {
|
||||
cp += sprintf(cp, " HASDESCRIPTOR");
|
||||
}
|
||||
if (closure->flags & BLOCK_NEEDS_FREE) {
|
||||
cp += sprintf(cp, " FREEME");
|
||||
}
|
||||
if (closure->flags & BLOCK_IS_GC) {
|
||||
cp += sprintf(cp, " ISGC");
|
||||
}
|
||||
if (closure->flags & BLOCK_HAS_COPY_DISPOSE) {
|
||||
cp += sprintf(cp, " HASHELP");
|
||||
}
|
||||
if (closure->flags & BLOCK_HAS_CTOR) {
|
||||
cp += sprintf(cp, " HASCTOR");
|
||||
}
|
||||
cp += sprintf(cp, "\nrefcount: %u\n", closure->flags & BLOCK_REFCOUNT_MASK);
|
||||
cp += sprintf(cp, "invoke: %p\n", closure->invoke);
|
||||
{
|
||||
struct Block_descriptor *dp = closure->descriptor;
|
||||
cp += sprintf(cp, "descriptor: %p\n", dp);
|
||||
cp += sprintf(cp, "descriptor->reserved: %lu\n", dp->reserved);
|
||||
cp += sprintf(cp, "descriptor->size: %lu\n", dp->size);
|
||||
|
||||
if (closure->flags & BLOCK_HAS_COPY_DISPOSE) {
|
||||
cp += sprintf(cp, "descriptor->copy helper: %p\n", dp->copy);
|
||||
cp += sprintf(cp, "descriptor->dispose helper: %p\n", dp->dispose);
|
||||
}
|
||||
}
|
||||
return buffer;
|
||||
}
|
||||
|
||||
|
||||
const char *_Block_byref_dump(struct Block_byref *src) {
|
||||
static char buffer[256];
|
||||
char *cp = buffer;
|
||||
cp += sprintf(cp, "byref data block %p contents:\n", src);
|
||||
cp += sprintf(cp, " forwarding: %p\n", src->forwarding);
|
||||
cp += sprintf(cp, " flags: 0x%x\n", src->flags);
|
||||
cp += sprintf(cp, " size: %d\n", src->size);
|
||||
if (src->flags & BLOCK_HAS_COPY_DISPOSE) {
|
||||
cp += sprintf(cp, " copy helper: %p\n", src->byref_keep);
|
||||
cp += sprintf(cp, " dispose helper: %p\n", src->byref_destroy);
|
||||
}
|
||||
return buffer;
|
||||
}
|
||||
|
||||
@@ -1,47 +0,0 @@
|
||||
# See docs/CMake.html for instructions about how to build Compiler-RT with CMake.
|
||||
|
||||
PROJECT( CompilerRT C )
|
||||
CMAKE_MINIMUM_REQUIRED( VERSION 2.6 )
|
||||
|
||||
set(PACKAGE_NAME compiler-rt)
|
||||
set(PACKAGE_VERSION 1.0svn)
|
||||
set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}")
|
||||
set(PACKAGE_BUGREPORT "llvmbugs@cs.uiuc.edu")
|
||||
|
||||
SET( CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/Modules )
|
||||
|
||||
# add definitions
|
||||
include(DefineCompilerFlags)
|
||||
|
||||
# Disallow in-source build
|
||||
INCLUDE( MacroEnsureOutOfSourceBuild )
|
||||
MACRO_ENSURE_OUT_OF_SOURCE_BUILD(
|
||||
"${PROJECT_NAME} requires an out of source build. Please create a separate build directory and run 'cmake /path/to/${PROJECT_NAME} [options]' there."
|
||||
)
|
||||
|
||||
INCLUDE( ConfigureChecks.cmake )
|
||||
CONFIGURE_FILE( config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config.h )
|
||||
|
||||
install(DIRECTORY include
|
||||
DESTINATION .
|
||||
PATTERN ".svn" EXCLUDE
|
||||
PATTERN "*.cmake" EXCLUDE
|
||||
PATTERN "*.in" EXCLUDE
|
||||
)
|
||||
|
||||
SET( Achitectures
|
||||
i386 ppc x86_64
|
||||
)
|
||||
|
||||
SET( Configurations
|
||||
Debug Release Profile
|
||||
)
|
||||
|
||||
# BlocksRuntime - some random cruft that got thrown in at the last minute, ignoring for now.
|
||||
# ADD_SUBDIRECTORY( BlocksRuntime )
|
||||
|
||||
ADD_SUBDIRECTORY( lib )
|
||||
|
||||
# Tests are being ignored for until the very basics are working.
|
||||
#INCLUDE( MacroAddCheckTest )
|
||||
#ADD_SUBDIRECTORY( test )
|
||||
@@ -1,21 +0,0 @@
|
||||
This file is a partial list of people who have contributed to the LLVM/CompilerRT
|
||||
project. If you have contributed a patch or made some other contribution to
|
||||
LLVM/CompilerRT, please submit a patch to this file to add yourself, and it will be
|
||||
done!
|
||||
|
||||
The list is sorted by surname and formatted to allow easy grepping and
|
||||
beautification by scripts. The fields are: name (N), email (E), web-address
|
||||
(W), PGP key ID and fingerprint (P), description (D), and snail-mail address
|
||||
(S).
|
||||
|
||||
N: Craig van Vliet
|
||||
E: cvanvliet@auroraux.org
|
||||
W: http://www.auroraux.org
|
||||
D: Code style and Readability fixes.
|
||||
|
||||
N: Edward O'Callaghan
|
||||
E: eocallaghan@auroraux.org
|
||||
W: http://www.auroraux.org
|
||||
D: CMake'ify Compiler-RT build system
|
||||
D: Maintain Solaris & AuroraUX ports of Compiler-RT
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
INCLUDE( CheckIncludeFile )
|
||||
INCLUDE( CheckFunctionExists )
|
||||
|
||||
SET( PACKAGE ${PACKAGE_NAME} )
|
||||
SET( VERSION ${PACKAGE_VERSION} )
|
||||
|
||||
SET( BINARYDIR ${CMAKE_BINARY_DIR} )
|
||||
SET( SOURCEDIR ${CMAKE_SOURCE_DIR} )
|
||||
|
||||
# HEADER FILES
|
||||
CHECK_INCLUDE_FILE( sys/byteorder.h HAVE_SYS_BYTEORDER_H )
|
||||
|
||||
# FUNCTIONS
|
||||
CHECK_FUNCTION_EXISTS( sysconf HAVE_SYSCONF )
|
||||
@@ -1,63 +0,0 @@
|
||||
==============================================================================
|
||||
LLVM Release License
|
||||
==============================================================================
|
||||
University of Illinois/NCSA
|
||||
Open Source License
|
||||
|
||||
Copyright (c) 2003-2009 University of Illinois at Urbana-Champaign.
|
||||
All rights reserved.
|
||||
|
||||
Developed by:
|
||||
|
||||
LLVM Team
|
||||
|
||||
University of Illinois at Urbana-Champaign
|
||||
|
||||
http://llvm.org
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal with
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
of the Software, and to permit persons to whom the Software is furnished to do
|
||||
so, subject to the following conditions:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions and the following disclaimers.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimers in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
* Neither the names of the LLVM Team, University of Illinois at
|
||||
Urbana-Champaign, nor the names of its contributors may be used to
|
||||
endorse or promote products derived from this Software without specific
|
||||
prior written permission.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE
|
||||
SOFTWARE.
|
||||
|
||||
==============================================================================
|
||||
Copyrights and Licenses for Third Party Software Distributed with LLVM:
|
||||
==============================================================================
|
||||
The LLVM software contains code written by third parties. Such software will
|
||||
have its own individual LICENSE.TXT file in the directory in which it appears.
|
||||
This file will describe the copyrights, license, and restrictions which apply
|
||||
to that code.
|
||||
|
||||
The disclaimer of warranty in the University of Illinois Open Source License
|
||||
applies to all code in the LLVM Distribution, and nothing in any of the
|
||||
other licenses gives permission to use the names of the LLVM Team or the
|
||||
University of Illinois to endorse or promote products derived from this
|
||||
Software.
|
||||
|
||||
The following pieces of software have additional or alternate copyrights,
|
||||
licenses, and/or restrictions:
|
||||
|
||||
Program Directory
|
||||
------- ---------
|
||||
@@ -1,194 +0,0 @@
|
||||
SubDirs := lib
|
||||
|
||||
# Set default rule before anything else.
|
||||
all::
|
||||
|
||||
include make/config.mk
|
||||
include make/util.mk
|
||||
# If SRCROOT is defined, assume we are doing an Apple style build. We
|
||||
# should be able to use RC_XBS for this but that is unused during
|
||||
# "make installsrc".
|
||||
ifdef SRCROOT
|
||||
include make/AppleBI.mk
|
||||
endif
|
||||
|
||||
# Make sure we don't build with a missing ProjObjRoot.
|
||||
ifeq ($(ProjObjRoot),)
|
||||
$(error Refusing to build with empty ProjObjRoot variable)
|
||||
endif
|
||||
|
||||
##############
|
||||
|
||||
###
|
||||
# Rules
|
||||
|
||||
###
|
||||
# Top level targets
|
||||
|
||||
# Provide default clean target which is extended by other templates.
|
||||
.PHONY: clean
|
||||
clean::
|
||||
|
||||
# Test
|
||||
.PHONY: test
|
||||
test:
|
||||
cd test/Unit && ./test
|
||||
|
||||
# Template: Config_template Config
|
||||
#
|
||||
# This template is used once per Config at the top-level.
|
||||
define Config_template
|
||||
$(call Set,ActiveConfig,$1)
|
||||
$(call Set,ActiveObjPath,$(ProjObjRoot)/$(ActiveConfig))
|
||||
$(call Set,ActiveLibGen,$(ActiveObjPath)/libcompiler_rt.Generic.a)
|
||||
$(call Set,ActiveLibOpt,$(ActiveObjPath)/libcompiler_rt.Optimized.a)
|
||||
|
||||
# The sublibraries to use for a generic version.
|
||||
$(call Set,GenericInputs,$(foreach arch,$(Archs),$(ActiveObjPath)/$(arch)/libcompiler_rt.Generic.a))
|
||||
# The sublibraries to use for an optimized version.
|
||||
$(call Set,OptimizedInputs,$(foreach arch,$(Archs),$(ActiveObjPath)/$(arch)/libcompiler_rt.Optimized.a))
|
||||
|
||||
# Provide top-level fat archive targets.
|
||||
$(ActiveLibGen): $(GenericInputs) $(ActiveObjPath)/.dir
|
||||
$(Summary) " UNIVERSAL: $(ActiveConfig): $$@"
|
||||
-$(Verb) $(RM) $$@
|
||||
$(Verb) $(Lipo) -create -output $$@ $(GenericInputs)
|
||||
$(ActiveLibOpt): $(OptimizedInputs) $(ActiveObjPath)/.dir
|
||||
$(Summary) " UNIVERSAL: $(ActiveConfig): $$@"
|
||||
-$(Verb) $(RM) $$@
|
||||
$(Verb) $(Lipo) -create -output $$@ $(OptimizedInputs)
|
||||
.PRECIOUS: $(ActiveObjPath)/.dir
|
||||
|
||||
# Add to target lists.
|
||||
all:: $(ActiveConfig) $(ActiveLibGen) $(ActiveLibOpt)
|
||||
|
||||
# Remove entire config directory on clean.
|
||||
clean:: $(ActiveObjPath)/.remove
|
||||
endef
|
||||
|
||||
# Template: CNA_template Config Arch
|
||||
#
|
||||
# This template is used once per Config/Arch at the top-level.
|
||||
define CNA_template
|
||||
$(call Set,ActiveConfig,$1)
|
||||
$(call Set,ActiveArch,$2)
|
||||
$(call Set,ActiveObjPath,$(ProjObjRoot)/$(ActiveConfig)/$(ActiveArch))
|
||||
$(call Set,ActiveLibGen,$(ActiveObjPath)/libcompiler_rt.Generic.a)
|
||||
$(call Set,ActiveLibOpt,$(ActiveObjPath)/libcompiler_rt.Optimized.a)
|
||||
|
||||
# Initialize inputs lists. This are extended by the CNA_subdir
|
||||
# template. The one tricky bit is that we need to use these quoted,
|
||||
# because they are not complete until the entire makefile has been
|
||||
# processed.
|
||||
$(call Set,GenericInputs.$(ActiveConfig).$(ActiveArch),)
|
||||
$(call Set,OptimizedInputs.$(ActiveConfig).$(ActiveArch),)
|
||||
# Final.Inputs is created once we have loaded all the subdirectories
|
||||
# and know what the correct inputs are.
|
||||
|
||||
# Provide top-level archive targets.
|
||||
$(ActiveLibGen): $(ActiveObjPath)/.dir
|
||||
$(Summary) " ARCHIVE: $(ActiveConfig)/$(ActiveArch): $$@"
|
||||
-$(Verb) $(RM) $$@
|
||||
$(Verb) $(Archive) $$@ $$(Generic.Inputs.$(ActiveConfig).$(ActiveArch))
|
||||
$(Verb) $(Ranlib) $$@
|
||||
# FIXME: The dependency on ActiveLibGen is a hack, this picks up the
|
||||
# dependencies on the generic inputs.
|
||||
$(ActiveLibOpt): $(ActiveLibGen) $(ActiveObjPath)/.dir
|
||||
$(Summary) " ARCHIVE: $(ActiveConfig)/$(ActiveArch): $$@"
|
||||
-$(Verb) $(RM) $$@
|
||||
$(Verb) $(Archive) $$@ $$(Final.Inputs.$(ActiveConfig).$(ActiveArch))
|
||||
$(Verb) $(Ranlib) $$@
|
||||
.PRECIOUS: $(ActiveObjPath)/.dir
|
||||
|
||||
# Provide some default "alias" targets.
|
||||
$(ActiveConfig):: $(ActiveLibGen) $(ActiveLibOpt)
|
||||
$(ActiveArch):: $(ActiveLibGen) $(ActiveLibOpt)
|
||||
$(ActiveConfig)-$(ActiveArch):: $(ActiveLibGen) $(ActiveLibOpt)
|
||||
endef
|
||||
|
||||
$(foreach config,$(Configs), \
|
||||
$(foreach arch,$(Archs), \
|
||||
$(eval $(call CNA_template,$(config),$(arch)))))
|
||||
|
||||
$(foreach config,$(Configs), \
|
||||
$(eval $(call Config_template,$(config))))
|
||||
|
||||
###
|
||||
# How to build things.
|
||||
|
||||
# Define rules for building on each configuration & architecture. This
|
||||
# is not exactly obvious, but variables inside the template are being
|
||||
# expanded during the make processing, so automatic variables must be
|
||||
# quoted and normal assignment cannot be used.
|
||||
|
||||
# Template: CNA_template Config Arch Dir
|
||||
# Uses: GetArgs, Dependencies, ObjNames
|
||||
#
|
||||
# This template is used once per Config/Arch/Dir.
|
||||
define CNA_subdir_template
|
||||
$(call Set,ActiveConfig,$1)
|
||||
$(call Set,ActiveArch,$2)
|
||||
$(call Set,ActiveDir,$3)
|
||||
$(call Set,ActiveSrcPath,$(ProjSrcRoot)/$(ActiveDir))
|
||||
$(call Set,ActiveObjPath,$(ProjObjRoot)/$(ActiveDir)/$(ActiveConfig)/$(ActiveArch))
|
||||
|
||||
$(call Set,ActiveFlags,$(call GetArgs,$(ActiveConfig),$(ActiveArch)))
|
||||
$(call Set,ActiveObjects,$(ObjNames:%=$(ActiveObjPath)/%))
|
||||
|
||||
# Add to the input list for the appropriate library and update the
|
||||
# dependency.
|
||||
$(call Append,$(Target).Inputs.$(ActiveConfig).$(ActiveArch),$(ActiveObjects))
|
||||
$(ProjObjRoot)/$(ActiveConfig)/$(ActiveArch)/libcompiler_rt.$(Target).a: $(ActiveObjects)
|
||||
|
||||
$(ActiveObjPath)/%.o: $(ActiveSrcPath)/%.s $(Dependencies) $(ActiveObjPath)/.dir
|
||||
$(Summary) " ASSEMBLE: $(ActiveConfig)/$(ActiveArch): $$<"
|
||||
$(Verb) $(CC) -c -o $$@ $(ActiveFlags) $$<
|
||||
.PRECIOUS: $(ActiveObjPath)/.dir
|
||||
|
||||
$(ActiveObjPath)/%.o: $(ActiveSrcPath)/%.c $(Dependencies) $(ActiveObjPath)/.dir
|
||||
$(Summary) " COMPILE: $(ActiveConfig)/$(ActiveArch): $$<"
|
||||
$(Verb) $(CC) -c -o $$@ $(ActiveFlags) $$<
|
||||
.PRECIOUS: $(ActiveObjPath)/.dir
|
||||
|
||||
# Remove entire config directory on clean.
|
||||
clean:: $(ProjObjRoot)/$(ActiveDir)/$(ActiveConfig)/.remove
|
||||
endef
|
||||
|
||||
###
|
||||
# Directory handling magic.
|
||||
|
||||
# Create directories as needed, and timestamp their creation.
|
||||
%/.dir:
|
||||
$(Summary) " MKDIR: $*"
|
||||
$(Verb) $(MKDIR) $* > /dev/null
|
||||
$(Verb) $(DATE) > $@
|
||||
|
||||
# Remove directories
|
||||
%/.remove:
|
||||
$(Verb) $(RM) -r $*
|
||||
|
||||
###
|
||||
# Include child makefile fragments
|
||||
|
||||
$(foreach subdir,$(SubDirs),$(eval include $(subdir)/Makefile.mk))
|
||||
|
||||
###
|
||||
# Determine the actual inputs for an optimized library.
|
||||
|
||||
# Template: Final_CNA_template Config Arch
|
||||
# Uses: GetArgs, Dependencies, ObjNames
|
||||
#
|
||||
# This template is used once per Config/Arch.
|
||||
define Final_CNA_template
|
||||
$(call Set,ActiveConfig,$1)
|
||||
$(call Set,ActiveArch,$2)
|
||||
|
||||
$(call Set,Final.Inputs.$(ActiveConfig).$(ActiveArch),\
|
||||
$(shell make/filter-inputs \
|
||||
$(Optimized.Inputs.$(ActiveConfig).$(ActiveArch)) \
|
||||
$(Generic.Inputs.$(ActiveConfig).$(ActiveArch))))
|
||||
endef
|
||||
|
||||
$(foreach config,$(Configs), \
|
||||
$(foreach arch,$(Archs), \
|
||||
$(eval $(call Final_CNA_template,$(config),$(arch)))))
|
||||
@@ -1,133 +0,0 @@
|
||||
Compiler-RT
|
||||
================================
|
||||
|
||||
This directory and its subdirectories contain source code for the compiler
|
||||
support routines.
|
||||
|
||||
Compiler-RT is open source software. You may freely distribute it under the
|
||||
terms of the license agreement found in LICENSE.txt.
|
||||
|
||||
================================
|
||||
|
||||
This is a replacement library for libgcc. Each function is contained
|
||||
in its own file. Each function has a corresponding unit test under
|
||||
test/Unit.
|
||||
|
||||
A rudimentary script to test each file is in the file called
|
||||
test/Unit/test.
|
||||
|
||||
Here is the specification for this library:
|
||||
|
||||
http://gcc.gnu.org/onlinedocs/gccint/Libgcc.html#Libgcc
|
||||
|
||||
Here is a synopsis of the contents of this library:
|
||||
|
||||
typedef int si_int;
|
||||
typedef unsigned su_int;
|
||||
|
||||
typedef long long di_int;
|
||||
typedef unsigned long long du_int;
|
||||
|
||||
// Integral bit manipulation
|
||||
|
||||
di_int __ashldi3(di_int a, si_int b); // a << b
|
||||
di_int __ashrdi3(di_int a, si_int b); // a >> b arithmetic (sign fill)
|
||||
di_int __lshrdi3(di_int a, si_int b); // a >> b logical (zero fill)
|
||||
|
||||
si_int __clzsi2(si_int a); // count leading zeros
|
||||
si_int __clzdi2(di_int a); // count leading zeros
|
||||
si_int __ctzsi2(si_int a); // count trailing zeros
|
||||
si_int __ctzdi2(di_int a); // count trailing zeros
|
||||
|
||||
si_int __ffsdi2(di_int a); // find least significant 1 bit
|
||||
|
||||
si_int __paritysi2(si_int a); // bit parity
|
||||
si_int __paritydi2(di_int a); // bit parity
|
||||
|
||||
si_int __popcountsi2(si_int a); // bit population
|
||||
si_int __popcountdi2(di_int a); // bit population
|
||||
|
||||
// Integral arithmetic
|
||||
|
||||
di_int __negdi2 (di_int a); // -a
|
||||
di_int __muldi3 (di_int a, di_int b); // a * b
|
||||
di_int __divdi3 (di_int a, di_int b); // a / b signed
|
||||
du_int __udivdi3 (du_int a, du_int b); // a / b unsigned
|
||||
di_int __moddi3 (di_int a, di_int b); // a % b signed
|
||||
du_int __umoddi3 (du_int a, du_int b); // a % b unsigned
|
||||
du_int __udivmoddi4(du_int a, du_int b, du_int* rem); // a / b, *rem = a % b
|
||||
|
||||
// Integral arithmetic with trapping overflow
|
||||
|
||||
si_int __absvsi2(si_int a); // abs(a)
|
||||
di_int __absvdi2(di_int a); // abs(a)
|
||||
|
||||
si_int __negvsi2(si_int a); // -a
|
||||
di_int __negvdi2(di_int a); // -a
|
||||
|
||||
si_int __addvsi3(si_int a, si_int b); // a + b
|
||||
di_int __addvdi3(di_int a, di_int b); // a + b
|
||||
|
||||
si_int __subvsi3(si_int a, si_int b); // a - b
|
||||
di_int __subvdi3(di_int a, di_int b); // a - b
|
||||
|
||||
si_int __mulvsi3(si_int a, si_int b); // a * b
|
||||
di_int __mulvdi3(di_int a, di_int b); // a * b
|
||||
|
||||
// Integral comparison: a < b -> 0
|
||||
// a == b -> 1
|
||||
// a > b -> 2
|
||||
|
||||
si_int __cmpdi2 (di_int a, di_int b);
|
||||
si_int __ucmpdi2(du_int a, du_int b);
|
||||
|
||||
// Integral / floating point conversion
|
||||
|
||||
di_int __fixsfdi( float a);
|
||||
di_int __fixdfdi( double a);
|
||||
di_int __fixxfdi(long double a);
|
||||
|
||||
su_int __fixunssfsi( float a);
|
||||
su_int __fixunsdfsi( double a);
|
||||
su_int __fixunsxfsi(long double a);
|
||||
|
||||
du_int __fixunssfdi( float a);
|
||||
du_int __fixunsdfdi( double a);
|
||||
du_int __fixunsxfdi(long double a);
|
||||
|
||||
float __floatdisf(di_int a);
|
||||
double __floatdidf(di_int a);
|
||||
long double __floatdixf(di_int a);
|
||||
|
||||
float __floatundisf(du_int a);
|
||||
double __floatundidf(du_int a);
|
||||
long double __floatundixf(du_int a);
|
||||
|
||||
// Floating point raised to integer power
|
||||
|
||||
float __powisf2( float a, si_int b); // a ^ b
|
||||
double __powidf2( double a, si_int b); // a ^ b
|
||||
long double __powixf2(long double a, si_int b); // a ^ b
|
||||
|
||||
// Complex arithmetic
|
||||
|
||||
// (a + ib) * (c + id)
|
||||
|
||||
float _Complex __mulsc3( float a, float b, float c, float d);
|
||||
double _Complex __muldc3(double a, double b, double c, double d);
|
||||
long double _Complex __mulxc3(long double a, long double b,
|
||||
long double c, long double d);
|
||||
|
||||
// (a + ib) / (c + id)
|
||||
|
||||
float _Complex __divsc3( float a, float b, float c, float d);
|
||||
double _Complex __divdc3(double a, double b, double c, double d);
|
||||
long double _Complex __divxc3(long double a, long double b,
|
||||
long double c, long double d);
|
||||
|
||||
Preconditions are listed for each function at the definition when there are any.
|
||||
Any preconditions reflect the specification at
|
||||
http://gcc.gnu.org/onlinedocs/gccint/Libgcc.html#Libgcc.
|
||||
|
||||
Assumptions are listed in "int_lib.h", and in individual files. Where possible
|
||||
assumptions are checked at compile time.
|
||||
@@ -1,4 +0,0 @@
|
||||
# Define compiler flags
|
||||
|
||||
#ADD_DEFINITIONS( -Wall -W -Werror -pedantic )
|
||||
ADD_DEFINITIONS( -std=c99 -Wall -Wextra -W -pedantic -Wno-unused-parameter )
|
||||
@@ -1,11 +0,0 @@
|
||||
# - macro_add_check_test(test_name test_source linklib1 ... linklibN)
|
||||
|
||||
ENABLE_TESTING()
|
||||
include(CTest)
|
||||
set(CMAKE_C_FLAGS_PROFILING "-g -pg")
|
||||
|
||||
macro (MACRO_ADD_CHECK_TEST _testName _testSource)
|
||||
add_executable(${_testName} ${_testSource})
|
||||
target_link_libraries(${_testName} ${ARGN})
|
||||
add_test(${_testName} ${CMAKE_CURRENT_BINARY_DIR}/${_testName})
|
||||
endmacro (MACRO_ADD_CHECK_TEST)
|
||||
@@ -1,18 +0,0 @@
|
||||
# MACRO_ENSURE_OUT_OF_SOURCE_BUILD(<errorMessage>)
|
||||
|
||||
macro( MACRO_ENSURE_OUT_OF_SOURCE_BUILD _errorMessage )
|
||||
|
||||
string( COMPARE EQUAL "${CMAKE_SOURCE_DIR}" "${CMAKE_BINARY_DIR}" _insource )
|
||||
if( _insource )
|
||||
message( SEND_ERROR "${_errorMessage}" )
|
||||
message( FATAL_ERROR
|
||||
"In-source builds are not allowed.
|
||||
CMake would overwrite the makefiles distributed with Compiler-RT.
|
||||
Please create a directory and run cmake from there, passing the path
|
||||
to this source directory as the last argument.
|
||||
This process created the file `CMakeCache.txt' and the directory `CMakeFiles'.
|
||||
Please delete them."
|
||||
)
|
||||
endif( _insource )
|
||||
|
||||
endmacro( MACRO_ENSURE_OUT_OF_SOURCE_BUILD )
|
||||
@@ -1,2 +0,0 @@
|
||||
#cmakedefine HAVE_SYS_BYTEORDER_H ${HAVE_SYS_BYTEORDER}
|
||||
#cmakedefine __Apple__ ${CMAKE_HOST_APPLE}
|
||||
@@ -1,65 +0,0 @@
|
||||
#
|
||||
# Create a library called "CompilerRT" which includes the source files.
|
||||
|
||||
#INCLUDE_DIRECTORIES(
|
||||
# ${CMAKE_CURRENT_BINARY_DIR}
|
||||
#)
|
||||
|
||||
# Generic functions needed for each architecture
|
||||
# libcompiler_rt.Generic.a libcompiler_rt.Optimized.a
|
||||
|
||||
SET( SRCS
|
||||
absvdi2.c cmpdi2.c fixdfdi.c floatdidf.c moddi3.c negvti2.c ucmpdi2.c
|
||||
absvsi2.c cmpti2.c fixdfti.c floatdisf.c modsi3.c paritydi2.c ucmpti2.c
|
||||
absvti2.c ctzdi2.c fixsfdi.c floatdixf.c modti3.c paritysi2.c udivdi3.c
|
||||
addvdi3.c ctzsi2.c fixsfti.c floattidf.c muldc3.c parityti2.c udivmoddi4.c
|
||||
addvsi3.c ctzti2.c fixunsdfdi.c floattisf.c muldi3.c popcountdi2.c udivmodti4.c
|
||||
addvti3.c divdc3.c fixunsdfsi.c floattixf.c mulsc3.c popcountsi2.c udivsi3.c
|
||||
apple_versioning.c divdi3.c fixunsdfti.c floatundidf.c multi3.c popcountti2.c udivti3.c
|
||||
ashldi3.c divsc3.c fixunssfdi.c floatundisf.c mulvdi3.c powidf2.c umoddi3.c
|
||||
ashlti3.c divsi3.c fixunssfsi.c floatundixf.c mulvsi3.c powisf2.c umodsi3.c
|
||||
ashrdi3.c divti3.c fixunssfti.c floatuntidf.c mulvti3.c powitf2.c umodti3.c
|
||||
ashrti3.c divxc3.c fixunsxfdi.c floatuntisf.c mulxc3.c powixf2.c
|
||||
clear_cache.c enable_execute_stack.c fixunsxfsi.c floatuntixf.c negdi2.c subvdi3.c
|
||||
clzdi2.c eprintf.c fixunsxfti.c gcc_personality_v0.c negti2.c subvsi3.c
|
||||
clzsi2.c ffsdi2.c fixxfdi.c lshrdi3.c negvdi2.c subvti3.c
|
||||
clzti2.c ffsti2.c fixxfti.c lshrti3.c negvsi2.c trampoline_setup.c
|
||||
)
|
||||
|
||||
# Generic
|
||||
SET( Common_SRCS
|
||||
absvdi2.c absvsi2.c addvdi3.c addvsi3.c ashldi3.c ashrdi3.c
|
||||
clear_cache.c clzdi2.c clzsi2.c cmpdi2.c ctzdi2.c ctzsi2.c
|
||||
divdc3.c divdi3.c divsc3.c enable_execute_stack.c ffsdi2.c
|
||||
fixdfdi.c fixsfdi.c fixunsdfdi.c fixunsdfsi.c fixunssfdi.c
|
||||
fixunssfsi.c floatdidf.c floatdisf.c floatundidf.c floatundisf.c
|
||||
gcc_personality_v0.c lshrdi3.c moddi3.c muldc3.c muldi3.c
|
||||
mulsc3.c mulvdi3.c mulvsi3.c negdi2.c negvdi2.c negvsi2.c
|
||||
paritydi2.c paritysi2.c popcountdi2.c popcountsi2.c powidf2.c
|
||||
powisf2.c subvdi3.c subvsi3.c ucmpdi2.c udivdi3.c
|
||||
udivmoddi4.c umoddi3.c apple_versioning.c eprintf.c
|
||||
)
|
||||
|
||||
SET( i386_Functions
|
||||
divxc3.c fixunsxfdi.c fixunsxfsi.c fixxfdi.c
|
||||
floatdixf.c floatundixf.c mulxc3.c powixf2.c
|
||||
)
|
||||
|
||||
# Optimized functions for each architecture
|
||||
|
||||
# Commenting out for the min until the basics are working first.
|
||||
# ADD_SUBDIRECTORY( ppc )
|
||||
# ADD_SUBDIRECTORY( x86_64 )
|
||||
# ADD_SUBDIRECTORY( i386 )
|
||||
|
||||
#FOREACH( LOOP_VAR ${Achitectures} )
|
||||
# See ARCHIVE_OUTPUT_DIRECTORY docs.
|
||||
#${CMAKE_ARCHIVE_OUTPUT_DIRECTORY}/${LOOP_VAR}
|
||||
#ENDFOREACH
|
||||
|
||||
ADD_LIBRARY( ${PROJECT_NAME}-Common STATIC ${Common_SRCS} )
|
||||
#ADD_LIBRARY( ${PROJECT_NAME}-i386 STATIC ${i386_Functions} )
|
||||
|
||||
# [[debug|optimized|general]
|
||||
#TARGET_LINK_LIBRARIES( ${PROJECT_NAME} ${PROJECT_NAME}-Common optimized ${PROJECT_NAME}-i386 )
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
#===- lib/Makefile.mk --------------------------------------*- Makefile -*--===#
|
||||
#
|
||||
# The LLVM Compiler Infrastructure
|
||||
#
|
||||
# This file is distributed under the University of Illinois Open Source
|
||||
# License. See LICENSE.TXT for details.
|
||||
#
|
||||
#===------------------------------------------------------------------------===#
|
||||
|
||||
Dir := lib
|
||||
SubDirs := i386 ppc x86_64
|
||||
|
||||
Sources := $(foreach file,$(wildcard $(Dir)/*.c),$(notdir $(file)))
|
||||
ObjNames := $(Sources:%.c=%.o)
|
||||
Target := Generic
|
||||
|
||||
# FIXME: use automatic dependencies?
|
||||
Dependencies := $(wildcard $(Dir)/*.h)
|
||||
|
||||
include make/subdir.mk
|
||||
@@ -1,30 +0,0 @@
|
||||
/*===-- absvdi2.c - Implement __absvdi2 -----------------------------------===
|
||||
*
|
||||
* The LLVM Compiler Infrastructure
|
||||
*
|
||||
* This file is distributed under the University of Illinois Open Source
|
||||
* License. See LICENSE.TXT for details.
|
||||
*
|
||||
*===----------------------------------------------------------------------===
|
||||
*
|
||||
* This file implements __absvdi2 for the compiler_rt library.
|
||||
*
|
||||
*===----------------------------------------------------------------------===
|
||||
*/
|
||||
|
||||
#include "int_lib.h"
|
||||
#include <stdlib.h>
|
||||
|
||||
/* Returns: absolute value */
|
||||
|
||||
/* Effects: aborts if abs(x) < 0 */
|
||||
|
||||
di_int
|
||||
__absvdi2(di_int a)
|
||||
{
|
||||
const int N = (int)(sizeof(di_int) * CHAR_BIT);
|
||||
if (a == ((di_int)1 << (N-1)))
|
||||
abort();
|
||||
const di_int t = a >> (N - 1);
|
||||
return (a ^ t) - t;
|
||||
}
|
||||
@@ -1,30 +0,0 @@
|
||||
/* ===-- absvsi2.c - Implement __absvsi2 -----------------------------------===
|
||||
*
|
||||
* The LLVM Compiler Infrastructure
|
||||
*
|
||||
* This file is distributed under the University of Illinois Open Source
|
||||
* License. See LICENSE.TXT for details.
|
||||
*
|
||||
* ===----------------------------------------------------------------------===
|
||||
*
|
||||
* This file implements __absvsi2 for the compiler_rt library.
|
||||
*
|
||||
* ===----------------------------------------------------------------------===
|
||||
*/
|
||||
|
||||
#include "int_lib.h"
|
||||
#include <stdlib.h>
|
||||
|
||||
/* Returns: absolute value */
|
||||
|
||||
/* Effects: aborts if abs(x) < 0 */
|
||||
|
||||
si_int
|
||||
__absvsi2(si_int a)
|
||||
{
|
||||
const int N = (int)(sizeof(si_int) * CHAR_BIT);
|
||||
if (a == (1 << (N-1)))
|
||||
abort();
|
||||
const si_int t = a >> (N - 1);
|
||||
return (a ^ t) - t;
|
||||
}
|
||||
@@ -1,34 +0,0 @@
|
||||
/* ===-- absvti2.c - Implement __absvdi2 -----------------------------------===
|
||||
*
|
||||
* The LLVM Compiler Infrastructure
|
||||
*
|
||||
* This file is distributed under the University of Illinois Open Source
|
||||
* License. See LICENSE.TXT for details.
|
||||
*
|
||||
* ===----------------------------------------------------------------------===
|
||||
*
|
||||
* This file implements __absvti2 for the compiler_rt library.
|
||||
*
|
||||
* ===----------------------------------------------------------------------===
|
||||
*/
|
||||
|
||||
#if __x86_64
|
||||
|
||||
#include "int_lib.h"
|
||||
#include <stdlib.h>
|
||||
|
||||
/* Returns: absolute value */
|
||||
|
||||
/* Effects: aborts if abs(x) < 0 */
|
||||
|
||||
ti_int
|
||||
__absvti2(ti_int a)
|
||||
{
|
||||
const int N = (int)(sizeof(ti_int) * CHAR_BIT);
|
||||
if (a == ((ti_int)1 << (N-1)))
|
||||
abort();
|
||||
const ti_int s = a >> (N - 1);
|
||||
return (a ^ s) - s;
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -1,37 +0,0 @@
|
||||
/* ===-- addvdi3.c - Implement __addvdi3 -----------------------------------===
|
||||
*
|
||||
* The LLVM Compiler Infrastructure
|
||||
*
|
||||
* This file is distributed under the University of Illinois Open Source
|
||||
* License. See LICENSE.TXT for details.
|
||||
*
|
||||
* ===----------------------------------------------------------------------===
|
||||
*
|
||||
* This file implements __addvdi3 for the compiler_rt library.
|
||||
*
|
||||
* ===----------------------------------------------------------------------===
|
||||
*/
|
||||
|
||||
#include "int_lib.h"
|
||||
#include <stdlib.h>
|
||||
|
||||
/* Returns: a + b */
|
||||
|
||||
/* Effects: aborts if a + b overflows */
|
||||
|
||||
di_int
|
||||
__addvdi3(di_int a, di_int b)
|
||||
{
|
||||
di_int s = a + b;
|
||||
if (b >= 0)
|
||||
{
|
||||
if (s < a)
|
||||
abort();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (s >= a)
|
||||
abort();
|
||||
}
|
||||
return s;
|
||||
}
|
||||
@@ -1,37 +0,0 @@
|
||||
/* ===-- addvsi3.c - Implement __addvsi3 -----------------------------------===
|
||||
*
|
||||
* The LLVM Compiler Infrastructure
|
||||
*
|
||||
* This file is distributed under the University of Illinois Open Source
|
||||
* License. See LICENSE.TXT for details.
|
||||
*
|
||||
* ===----------------------------------------------------------------------===
|
||||
*
|
||||
* This file implements __addvsi3 for the compiler_rt library.
|
||||
*
|
||||
* ===----------------------------------------------------------------------===
|
||||
*/
|
||||
|
||||
#include "int_lib.h"
|
||||
#include <stdlib.h>
|
||||
|
||||
/* Returns: a + b */
|
||||
|
||||
/* Effects: aborts if a + b overflows */
|
||||
|
||||
si_int
|
||||
__addvsi3(si_int a, si_int b)
|
||||
{
|
||||
si_int s = a + b;
|
||||
if (b >= 0)
|
||||
{
|
||||
if (s < a)
|
||||
abort();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (s >= a)
|
||||
abort();
|
||||
}
|
||||
return s;
|
||||
}
|
||||
@@ -1,41 +0,0 @@
|
||||
/* ===-- addvti3.c - Implement __addvti3 -----------------------------------===
|
||||
*
|
||||
* The LLVM Compiler Infrastructure
|
||||
*
|
||||
* This file is distributed under the University of Illinois Open Source
|
||||
* License. See LICENSE.TXT for details.
|
||||
*
|
||||
* ===----------------------------------------------------------------------===
|
||||
*
|
||||
* This file implements __addvti3 for the compiler_rt library.
|
||||
*
|
||||
* ===----------------------------------------------------------------------===
|
||||
*/
|
||||
|
||||
#if __x86_64
|
||||
|
||||
#include "int_lib.h"
|
||||
#include <stdlib.h>
|
||||
|
||||
/* Returns: a + b */
|
||||
|
||||
/* Effects: aborts if a + b overflows */
|
||||
|
||||
ti_int
|
||||
__addvti3(ti_int a, ti_int b)
|
||||
{
|
||||
ti_int s = a + b;
|
||||
if (b >= 0)
|
||||
{
|
||||
if (s < a)
|
||||
abort();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (s >= a)
|
||||
abort();
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -1,145 +0,0 @@
|
||||
/* ===-- apple_versioning.c - Adds versioning symbols for ld ---------------===
|
||||
*
|
||||
* The LLVM Compiler Infrastructure
|
||||
*
|
||||
* This file is distributed under the University of Illinois Open Source
|
||||
* License. See LICENSE.TXT for details.
|
||||
*
|
||||
* ===----------------------------------------------------------------------===
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#if __APPLE__
|
||||
#if __ppc__
|
||||
#define NOT_HERE_BEFORE_10_6(sym) \
|
||||
extern const char sym##_tmp3 __asm("$ld$hide$os10.3$_" #sym ); \
|
||||
__attribute__((visibility("default"))) const char sym##_tmp3 = 0; \
|
||||
extern const char sym##_tmp4 __asm("$ld$hide$os10.4$_" #sym ); \
|
||||
__attribute__((visibility("default"))) const char sym##_tmp4 = 0; \
|
||||
extern const char sym##_tmp5 __asm("$ld$hide$os10.5$_" #sym ); \
|
||||
__attribute__((visibility("default"))) const char sym##_tmp5 = 0;
|
||||
#else
|
||||
#define NOT_HERE_BEFORE_10_6(sym) \
|
||||
extern const char sym##_tmp4 __asm("$ld$hide$os10.4$_" #sym ); \
|
||||
__attribute__((visibility("default"))) const char sym##_tmp4 = 0; \
|
||||
extern const char sym##_tmp5 __asm("$ld$hide$os10.5$_" #sym ); \
|
||||
__attribute__((visibility("default"))) const char sym##_tmp5 = 0;
|
||||
#endif /* __ppc__ */
|
||||
|
||||
|
||||
/* Symbols in libSystem.dylib in 10.6 and later,
|
||||
* but are in libgcc_s.dylib in earlier versions
|
||||
*/
|
||||
|
||||
NOT_HERE_BEFORE_10_6(__absvdi2)
|
||||
NOT_HERE_BEFORE_10_6(__absvsi2)
|
||||
NOT_HERE_BEFORE_10_6(__absvti2)
|
||||
NOT_HERE_BEFORE_10_6(__addvdi3)
|
||||
NOT_HERE_BEFORE_10_6(__addvsi3)
|
||||
NOT_HERE_BEFORE_10_6(__addvti3)
|
||||
NOT_HERE_BEFORE_10_6(__ashldi3)
|
||||
NOT_HERE_BEFORE_10_6(__ashlti3)
|
||||
NOT_HERE_BEFORE_10_6(__ashrdi3)
|
||||
NOT_HERE_BEFORE_10_6(__ashrti3)
|
||||
NOT_HERE_BEFORE_10_6(__clear_cache)
|
||||
NOT_HERE_BEFORE_10_6(__clzdi2)
|
||||
NOT_HERE_BEFORE_10_6(__clzsi2)
|
||||
NOT_HERE_BEFORE_10_6(__clzti2)
|
||||
NOT_HERE_BEFORE_10_6(__cmpdi2)
|
||||
NOT_HERE_BEFORE_10_6(__cmpti2)
|
||||
NOT_HERE_BEFORE_10_6(__ctzdi2)
|
||||
NOT_HERE_BEFORE_10_6(__ctzsi2)
|
||||
NOT_HERE_BEFORE_10_6(__ctzti2)
|
||||
NOT_HERE_BEFORE_10_6(__divdc3)
|
||||
NOT_HERE_BEFORE_10_6(__divdi3)
|
||||
NOT_HERE_BEFORE_10_6(__divsc3)
|
||||
NOT_HERE_BEFORE_10_6(__divtc3)
|
||||
NOT_HERE_BEFORE_10_6(__divti3)
|
||||
NOT_HERE_BEFORE_10_6(__divxc3)
|
||||
NOT_HERE_BEFORE_10_6(__enable_execute_stack)
|
||||
NOT_HERE_BEFORE_10_6(__ffsdi2)
|
||||
NOT_HERE_BEFORE_10_6(__ffsti2)
|
||||
NOT_HERE_BEFORE_10_6(__fixdfdi)
|
||||
NOT_HERE_BEFORE_10_6(__fixdfti)
|
||||
NOT_HERE_BEFORE_10_6(__fixsfdi)
|
||||
NOT_HERE_BEFORE_10_6(__fixsfti)
|
||||
NOT_HERE_BEFORE_10_6(__fixtfdi)
|
||||
NOT_HERE_BEFORE_10_6(__fixunsdfdi)
|
||||
NOT_HERE_BEFORE_10_6(__fixunsdfsi)
|
||||
NOT_HERE_BEFORE_10_6(__fixunsdfti)
|
||||
NOT_HERE_BEFORE_10_6(__fixunssfdi)
|
||||
NOT_HERE_BEFORE_10_6(__fixunssfsi)
|
||||
NOT_HERE_BEFORE_10_6(__fixunssfti)
|
||||
NOT_HERE_BEFORE_10_6(__fixunstfdi)
|
||||
NOT_HERE_BEFORE_10_6(__fixunsxfdi)
|
||||
NOT_HERE_BEFORE_10_6(__fixunsxfsi)
|
||||
NOT_HERE_BEFORE_10_6(__fixunsxfti)
|
||||
NOT_HERE_BEFORE_10_6(__fixxfdi)
|
||||
NOT_HERE_BEFORE_10_6(__fixxfti)
|
||||
NOT_HERE_BEFORE_10_6(__floatdidf)
|
||||
NOT_HERE_BEFORE_10_6(__floatdisf)
|
||||
NOT_HERE_BEFORE_10_6(__floatditf)
|
||||
NOT_HERE_BEFORE_10_6(__floatdixf)
|
||||
NOT_HERE_BEFORE_10_6(__floattidf)
|
||||
NOT_HERE_BEFORE_10_6(__floattisf)
|
||||
NOT_HERE_BEFORE_10_6(__floattixf)
|
||||
NOT_HERE_BEFORE_10_6(__floatundidf)
|
||||
NOT_HERE_BEFORE_10_6(__floatundisf)
|
||||
NOT_HERE_BEFORE_10_6(__floatunditf)
|
||||
NOT_HERE_BEFORE_10_6(__floatundixf)
|
||||
NOT_HERE_BEFORE_10_6(__floatuntidf)
|
||||
NOT_HERE_BEFORE_10_6(__floatuntisf)
|
||||
NOT_HERE_BEFORE_10_6(__floatuntixf)
|
||||
NOT_HERE_BEFORE_10_6(__gcc_personality_v0)
|
||||
NOT_HERE_BEFORE_10_6(__lshrdi3)
|
||||
NOT_HERE_BEFORE_10_6(__lshrti3)
|
||||
NOT_HERE_BEFORE_10_6(__moddi3)
|
||||
NOT_HERE_BEFORE_10_6(__modti3)
|
||||
NOT_HERE_BEFORE_10_6(__muldc3)
|
||||
NOT_HERE_BEFORE_10_6(__muldi3)
|
||||
NOT_HERE_BEFORE_10_6(__mulsc3)
|
||||
NOT_HERE_BEFORE_10_6(__multc3)
|
||||
NOT_HERE_BEFORE_10_6(__multi3)
|
||||
NOT_HERE_BEFORE_10_6(__mulvdi3)
|
||||
NOT_HERE_BEFORE_10_6(__mulvsi3)
|
||||
NOT_HERE_BEFORE_10_6(__mulvti3)
|
||||
NOT_HERE_BEFORE_10_6(__mulxc3)
|
||||
NOT_HERE_BEFORE_10_6(__negdi2)
|
||||
NOT_HERE_BEFORE_10_6(__negti2)
|
||||
NOT_HERE_BEFORE_10_6(__negvdi2)
|
||||
NOT_HERE_BEFORE_10_6(__negvsi2)
|
||||
NOT_HERE_BEFORE_10_6(__negvti2)
|
||||
NOT_HERE_BEFORE_10_6(__paritydi2)
|
||||
NOT_HERE_BEFORE_10_6(__paritysi2)
|
||||
NOT_HERE_BEFORE_10_6(__parityti2)
|
||||
NOT_HERE_BEFORE_10_6(__popcountdi2)
|
||||
NOT_HERE_BEFORE_10_6(__popcountsi2)
|
||||
NOT_HERE_BEFORE_10_6(__popcountti2)
|
||||
NOT_HERE_BEFORE_10_6(__powidf2)
|
||||
NOT_HERE_BEFORE_10_6(__powisf2)
|
||||
NOT_HERE_BEFORE_10_6(__powitf2)
|
||||
NOT_HERE_BEFORE_10_6(__powixf2)
|
||||
NOT_HERE_BEFORE_10_6(__subvdi3)
|
||||
NOT_HERE_BEFORE_10_6(__subvsi3)
|
||||
NOT_HERE_BEFORE_10_6(__subvti3)
|
||||
NOT_HERE_BEFORE_10_6(__ucmpdi2)
|
||||
NOT_HERE_BEFORE_10_6(__ucmpti2)
|
||||
NOT_HERE_BEFORE_10_6(__udivdi3)
|
||||
NOT_HERE_BEFORE_10_6(__udivmoddi4)
|
||||
NOT_HERE_BEFORE_10_6(__udivmodti4)
|
||||
NOT_HERE_BEFORE_10_6(__udivti3)
|
||||
NOT_HERE_BEFORE_10_6(__umoddi3)
|
||||
NOT_HERE_BEFORE_10_6(__umodti3)
|
||||
|
||||
|
||||
#if __ppc__
|
||||
NOT_HERE_BEFORE_10_6(__gcc_qadd)
|
||||
NOT_HERE_BEFORE_10_6(__gcc_qdiv)
|
||||
NOT_HERE_BEFORE_10_6(__gcc_qmul)
|
||||
NOT_HERE_BEFORE_10_6(__gcc_qsub)
|
||||
NOT_HERE_BEFORE_10_6(__trampoline_setup)
|
||||
#endif /* __ppc__ */
|
||||
|
||||
|
||||
#endif /* __APPLE__*/
|
||||
@@ -1,41 +0,0 @@
|
||||
/* ====-- ashldi3.c - Implement __ashldi3 -----------------------------------===
|
||||
*
|
||||
* The LLVM Compiler Infrastructure
|
||||
*
|
||||
* This file is distributed under the University of Illinois Open Source
|
||||
* License. See LICENSE.TXT for details.
|
||||
*
|
||||
* ===----------------------------------------------------------------------===
|
||||
*
|
||||
* This file implements __ashldi3 for the compiler_rt library.
|
||||
*
|
||||
* ===----------------------------------------------------------------------===
|
||||
*/
|
||||
|
||||
#include "int_lib.h"
|
||||
|
||||
/* Returns: a << b */
|
||||
|
||||
/* Precondition: 0 <= b < bits_in_dword */
|
||||
|
||||
di_int
|
||||
__ashldi3(di_int a, si_int b)
|
||||
{
|
||||
const int bits_in_word = (int)(sizeof(si_int) * CHAR_BIT);
|
||||
dwords input;
|
||||
dwords result;
|
||||
input.all = a;
|
||||
if (b & bits_in_word) /* bits_in_word <= b < bits_in_dword */
|
||||
{
|
||||
result.s.low = 0;
|
||||
result.s.high = input.s.low << (b - bits_in_word);
|
||||
}
|
||||
else /* 0 <= b < bits_in_word */
|
||||
{
|
||||
if (b == 0)
|
||||
return a;
|
||||
result.s.low = input.s.low << b;
|
||||
result.s.high = (input.s.high << b) | (input.s.low >> (bits_in_word - b));
|
||||
}
|
||||
return result.all;
|
||||
}
|
||||
@@ -1,45 +0,0 @@
|
||||
/* ===-- ashlti3.c - Implement __ashlti3 -----------------------------------===
|
||||
*
|
||||
* The LLVM Compiler Infrastructure
|
||||
*
|
||||
* This file is distributed under the University of Illinois Open Source
|
||||
* License. See LICENSE.TXT for details.
|
||||
*
|
||||
* ===----------------------------------------------------------------------===
|
||||
*
|
||||
* This file implements __ashlti3 for the compiler_rt library.
|
||||
*
|
||||
* ===----------------------------------------------------------------------===
|
||||
*/
|
||||
|
||||
#if __x86_64
|
||||
|
||||
#include "int_lib.h"
|
||||
|
||||
/* Returns: a << b */
|
||||
|
||||
/* Precondition: 0 <= b < bits_in_tword */
|
||||
|
||||
ti_int
|
||||
__ashlti3(ti_int a, si_int b)
|
||||
{
|
||||
const int bits_in_dword = (int)(sizeof(di_int) * CHAR_BIT);
|
||||
twords input;
|
||||
twords result;
|
||||
input.all = a;
|
||||
if (b & bits_in_dword) /* bits_in_dword <= b < bits_in_tword */
|
||||
{
|
||||
result.s.low = 0;
|
||||
result.s.high = input.s.low << (b - bits_in_dword);
|
||||
}
|
||||
else /* 0 <= b < bits_in_dword */
|
||||
{
|
||||
if (b == 0)
|
||||
return a;
|
||||
result.s.low = input.s.low << b;
|
||||
result.s.high = (input.s.high << b) | (input.s.low >> (bits_in_dword - b));
|
||||
}
|
||||
return result.all;
|
||||
}
|
||||
|
||||
#endif /* __x86_64 */
|
||||
@@ -1,42 +0,0 @@
|
||||
/*===-- ashrdi3.c - Implement __ashrdi3 -----------------------------------===
|
||||
*
|
||||
* The LLVM Compiler Infrastructure
|
||||
*
|
||||
* This file is distributed under the University of Illinois Open Source
|
||||
* License. See LICENSE.TXT for details.
|
||||
*
|
||||
* ===----------------------------------------------------------------------===
|
||||
*
|
||||
* This file implements __ashrdi3 for the compiler_rt library.
|
||||
*
|
||||
* ===----------------------------------------------------------------------===
|
||||
*/
|
||||
|
||||
#include "int_lib.h"
|
||||
|
||||
/* Returns: arithmetic a >> b */
|
||||
|
||||
/* Precondition: 0 <= b < bits_in_dword */
|
||||
|
||||
di_int
|
||||
__ashrdi3(di_int a, si_int b)
|
||||
{
|
||||
const int bits_in_word = (int)(sizeof(si_int) * CHAR_BIT);
|
||||
dwords input;
|
||||
dwords result;
|
||||
input.all = a;
|
||||
if (b & bits_in_word) /* bits_in_word <= b < bits_in_dword */
|
||||
{
|
||||
/* result.s.high = input.s.high < 0 ? -1 : 0 */
|
||||
result.s.high = input.s.high >> (bits_in_word - 1);
|
||||
result.s.low = input.s.high >> (b - bits_in_word);
|
||||
}
|
||||
else /* 0 <= b < bits_in_word */
|
||||
{
|
||||
if (b == 0)
|
||||
return a;
|
||||
result.s.high = input.s.high >> b;
|
||||
result.s.low = (input.s.high << (bits_in_word - b)) | (input.s.low >> b);
|
||||
}
|
||||
return result.all;
|
||||
}
|
||||
@@ -1,46 +0,0 @@
|
||||
/* ===-- ashrti3.c - Implement __ashrti3 -----------------------------------===
|
||||
*
|
||||
* The LLVM Compiler Infrastructure
|
||||
*
|
||||
* This file is distributed under the University of Illinois Open Source
|
||||
* License. See LICENSE.TXT for details.
|
||||
*
|
||||
* ===----------------------------------------------------------------------===
|
||||
*
|
||||
* This file implements __ashrti3 for the compiler_rt library.
|
||||
*
|
||||
* ===----------------------------------------------------------------------===
|
||||
*/
|
||||
|
||||
#if __x86_64
|
||||
|
||||
#include "int_lib.h"
|
||||
|
||||
/* Returns: arithmetic a >> b */
|
||||
|
||||
/* Precondition: 0 <= b < bits_in_tword */
|
||||
|
||||
ti_int
|
||||
__ashrti3(ti_int a, si_int b)
|
||||
{
|
||||
const int bits_in_dword = (int)(sizeof(di_int) * CHAR_BIT);
|
||||
twords input;
|
||||
twords result;
|
||||
input.all = a;
|
||||
if (b & bits_in_dword) /* bits_in_dword <= b < bits_in_tword */
|
||||
{
|
||||
/* result.s.high = input.s.high < 0 ? -1 : 0 */
|
||||
result.s.high = input.s.high >> (bits_in_dword - 1);
|
||||
result.s.low = input.s.high >> (b - bits_in_dword);
|
||||
}
|
||||
else /* 0 <= b < bits_in_dword */
|
||||
{
|
||||
if (b == 0)
|
||||
return a;
|
||||
result.s.high = input.s.high >> b;
|
||||
result.s.low = (input.s.high << (bits_in_dword - b)) | (input.s.low >> b);
|
||||
}
|
||||
return result.all;
|
||||
}
|
||||
|
||||
#endif /* __x86_64 */
|
||||
@@ -1,40 +0,0 @@
|
||||
/* ===-- clear_cache.c - Implement __clear_cache ---------------------------===
|
||||
*
|
||||
* The LLVM Compiler Infrastructure
|
||||
*
|
||||
* This file is distributed under the University of Illinois Open Source
|
||||
* License. See LICENSE.TXT for details.
|
||||
*
|
||||
* ===----------------------------------------------------------------------===
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#if __APPLE__
|
||||
#include <libkern/OSCacheControl.h>
|
||||
#endif
|
||||
|
||||
/*
|
||||
* The compiler generates calls to __clear_cache() when creating
|
||||
* trampoline functions on the stack for use with nested functions.
|
||||
* It is expected to invalidate the instruction cache for the
|
||||
* specified range.
|
||||
*/
|
||||
|
||||
void __clear_cache(void* start, void* end)
|
||||
{
|
||||
#if __i386__ || __x86_64__
|
||||
/*
|
||||
* Intel processors have a unified instruction and data cache
|
||||
* so there is nothing to do
|
||||
*/
|
||||
#else
|
||||
#if __APPLE__
|
||||
/* On Darwin, sys_icache_invalidate() provides this functionality */
|
||||
sys_icache_invalidate(start, end-start);
|
||||
#else
|
||||
abort();
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -1,29 +0,0 @@
|
||||
/* ===-- clzdi2.c - Implement __clzdi2 -------------------------------------===
|
||||
*
|
||||
* The LLVM Compiler Infrastructure
|
||||
*
|
||||
* This file is distributed under the University of Illinois Open Source
|
||||
* License. See LICENSE.TXT for details.
|
||||
*
|
||||
* ===----------------------------------------------------------------------===
|
||||
*
|
||||
* This file implements __clzdi2 for the compiler_rt library.
|
||||
*
|
||||
* ===----------------------------------------------------------------------===
|
||||
*/
|
||||
|
||||
#include "int_lib.h"
|
||||
|
||||
/* Returns: the number of leading 0-bits */
|
||||
|
||||
/* Precondition: a != 0 */
|
||||
|
||||
si_int
|
||||
__clzdi2(di_int a)
|
||||
{
|
||||
dwords x;
|
||||
x.all = a;
|
||||
const si_int f = -(x.s.high == 0);
|
||||
return __builtin_clz((x.s.high & ~f) | (x.s.low & f)) +
|
||||
(f & ((si_int)(sizeof(si_int) * CHAR_BIT)));
|
||||
}
|
||||
@@ -1,53 +0,0 @@
|
||||
/* ===-- clzsi2.c - Implement __clzsi2 -------------------------------------===
|
||||
*
|
||||
* The LLVM Compiler Infrastructure
|
||||
*
|
||||
* This file is distributed under the University of Illinois Open Source
|
||||
* License. See LICENSE.TXT for details.
|
||||
*
|
||||
* ===----------------------------------------------------------------------===
|
||||
*
|
||||
* This file implements __clzsi2 for the compiler_rt library.
|
||||
*
|
||||
* ===----------------------------------------------------------------------===
|
||||
*/
|
||||
|
||||
#include "int_lib.h"
|
||||
|
||||
/* Returns: the number of leading 0-bits */
|
||||
|
||||
/* Precondition: a != 0 */
|
||||
|
||||
si_int
|
||||
__clzsi2(si_int a)
|
||||
{
|
||||
su_int x = (su_int)a;
|
||||
si_int t = ((x & 0xFFFF0000) == 0) << 4; /* if (x is small) t = 16 else 0 */
|
||||
x >>= 16 - t; /* x = [0 - 0xFFFF] */
|
||||
su_int r = t; /* r = [0, 16] */
|
||||
/* return r + clz(x) */
|
||||
t = ((x & 0xFF00) == 0) << 3;
|
||||
x >>= 8 - t; /* x = [0 - 0xFF] */
|
||||
r += t; /* r = [0, 8, 16, 24] */
|
||||
/* return r + clz(x) */
|
||||
t = ((x & 0xF0) == 0) << 2;
|
||||
x >>= 4 - t; /* x = [0 - 0xF] */
|
||||
r += t; /* r = [0, 4, 8, 12, 16, 20, 24, 28] */
|
||||
/* return r + clz(x) */
|
||||
t = ((x & 0xC) == 0) << 1;
|
||||
x >>= 2 - t; /* x = [0 - 3] */
|
||||
r += t; /* r = [0 - 30] and is even */
|
||||
/* return r + clz(x) */
|
||||
/* switch (x)
|
||||
* {
|
||||
* case 0:
|
||||
* return r + 2;
|
||||
* case 1:
|
||||
* return r + 1;
|
||||
* case 2:
|
||||
* case 3:
|
||||
* return r;
|
||||
* }
|
||||
*/
|
||||
return r + ((2 - x) & -((x & 2) == 0));
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
/* ===-- clzti2.c - Implement __clzti2 -------------------------------------===
|
||||
*
|
||||
* The LLVM Compiler Infrastructure
|
||||
*
|
||||
* This file is distributed under the University of Illinois Open Source
|
||||
* License. See LICENSE.TXT for details.
|
||||
*
|
||||
* ===----------------------------------------------------------------------===
|
||||
*
|
||||
* This file implements __clzti2 for the compiler_rt library.
|
||||
*
|
||||
* ===----------------------------------------------------------------------===
|
||||
*/
|
||||
|
||||
#if __x86_64
|
||||
|
||||
#include "int_lib.h"
|
||||
|
||||
/* Returns: the number of leading 0-bits */
|
||||
|
||||
/* Precondition: a != 0 */
|
||||
|
||||
si_int
|
||||
__clzti2(ti_int a)
|
||||
{
|
||||
twords x;
|
||||
x.all = a;
|
||||
const di_int f = -(x.high == 0);
|
||||
return __builtin_clzll((x.high & ~f) | (x.low & f)) +
|
||||
((si_int)f & ((si_int)(sizeof(di_int) * CHAR_BIT)));
|
||||
}
|
||||
|
||||
#endif /* __x86_64 */
|
||||
@@ -1,38 +0,0 @@
|
||||
/* ===-- cmpdi2.c - Implement __cmpdi2 -------------------------------------===
|
||||
*
|
||||
* The LLVM Compiler Infrastructure
|
||||
*
|
||||
* This file is distributed under the University of Illinois Open Source
|
||||
* License. See LICENSE.TXT for details.
|
||||
*
|
||||
* ===----------------------------------------------------------------------===
|
||||
*
|
||||
* This file implements __cmpdi2 for the compiler_rt library.
|
||||
*
|
||||
* ===----------------------------------------------------------------------===
|
||||
*/
|
||||
|
||||
#include "int_lib.h"
|
||||
|
||||
/* Returns: if (a < b) returns 0
|
||||
* if (a == b) returns 1
|
||||
* if (a > b) returns 2
|
||||
*/
|
||||
|
||||
si_int
|
||||
__cmpdi2(di_int a, di_int b)
|
||||
{
|
||||
dwords x;
|
||||
x.all = a;
|
||||
dwords y;
|
||||
y.all = b;
|
||||
if (x.s.high < y.s.high)
|
||||
return 0;
|
||||
if (x.s.high > y.s.high)
|
||||
return 2;
|
||||
if (x.s.low < y.s.low)
|
||||
return 0;
|
||||
if (x.s.low > y.s.low)
|
||||
return 2;
|
||||
return 1;
|
||||
}
|
||||
@@ -1,42 +0,0 @@
|
||||
/* ===-- cmpti2.c - Implement __cmpti2 -------------------------------------===
|
||||
*
|
||||
* The LLVM Compiler Infrastructure
|
||||
*
|
||||
* This file is distributed under the University of Illinois Open Source
|
||||
* License. See LICENSE.TXT for details.
|
||||
*
|
||||
* ===----------------------------------------------------------------------===
|
||||
*
|
||||
* This file implements __cmpti2 for the compiler_rt library.
|
||||
*
|
||||
* ===----------------------------------------------------------------------===
|
||||
*/
|
||||
|
||||
#if __x86_64
|
||||
|
||||
#include "int_lib.h"
|
||||
|
||||
/* Returns: if (a < b) returns 0
|
||||
* if (a == b) returns 1
|
||||
* if (a > b) returns 2
|
||||
*/
|
||||
|
||||
si_int
|
||||
__cmpti2(ti_int a, ti_int b)
|
||||
{
|
||||
twords x;
|
||||
x.all = a;
|
||||
twords y;
|
||||
y.all = b;
|
||||
if (x.high < y.high)
|
||||
return 0;
|
||||
if (x.high > y.high)
|
||||
return 2;
|
||||
if (x.low < y.low)
|
||||
return 0;
|
||||
if (x.low > y.low)
|
||||
return 2;
|
||||
return 1;
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -1,29 +0,0 @@
|
||||
/* ===-- ctzdi2.c - Implement __ctzdi2 -------------------------------------===
|
||||
*
|
||||
* The LLVM Compiler Infrastructure
|
||||
*
|
||||
* This file is distributed under the University of Illinois Open Source
|
||||
* License. See LICENSE.TXT for details.
|
||||
*
|
||||
* ===----------------------------------------------------------------------===
|
||||
*
|
||||
* This file implements __ctzdi2 for the compiler_rt library.
|
||||
*
|
||||
* ===----------------------------------------------------------------------===
|
||||
*/
|
||||
|
||||
#include "int_lib.h"
|
||||
|
||||
/* Returns: the number of trailing 0-bits */
|
||||
|
||||
/* Precondition: a != 0 */
|
||||
|
||||
si_int
|
||||
__ctzdi2(di_int a)
|
||||
{
|
||||
dwords x;
|
||||
x.all = a;
|
||||
const si_int f = -(x.s.low == 0);
|
||||
return __builtin_ctz((x.s.high & f) | (x.s.low & ~f)) +
|
||||
(f & ((si_int)(sizeof(si_int) * CHAR_BIT)));
|
||||
}
|
||||
@@ -1,57 +0,0 @@
|
||||
/* ===-- ctzsi2.c - Implement __ctzsi2 -------------------------------------===
|
||||
*
|
||||
* The LLVM Compiler Infrastructure
|
||||
*
|
||||
* This file is distributed under the University of Illinois Open Source
|
||||
* License. See LICENSE.TXT for details.
|
||||
*
|
||||
* ===----------------------------------------------------------------------===
|
||||
*
|
||||
* This file implements __ctzsi2 for the compiler_rt library.
|
||||
*
|
||||
* ===----------------------------------------------------------------------===
|
||||
*/
|
||||
|
||||
#include "int_lib.h"
|
||||
|
||||
/* Returns: the number of trailing 0-bits */
|
||||
|
||||
/* Precondition: a != 0 */
|
||||
|
||||
si_int
|
||||
__ctzsi2(si_int a)
|
||||
{
|
||||
su_int x = (su_int)a;
|
||||
si_int t = ((x & 0x0000FFFF) == 0) << 4; /* if (x has no small bits) t = 16 else 0 */
|
||||
x >>= t; /* x = [0 - 0xFFFF] + higher garbage bits */
|
||||
su_int r = t; /* r = [0, 16] */
|
||||
/* return r + ctz(x) */
|
||||
t = ((x & 0x00FF) == 0) << 3;
|
||||
x >>= t; /* x = [0 - 0xFF] + higher garbage bits */
|
||||
r += t; /* r = [0, 8, 16, 24] */
|
||||
/* return r + ctz(x) */
|
||||
t = ((x & 0x0F) == 0) << 2;
|
||||
x >>= t; /* x = [0 - 0xF] + higher garbage bits */
|
||||
r += t; /* r = [0, 4, 8, 12, 16, 20, 24, 28] */
|
||||
/* return r + ctz(x) */
|
||||
t = ((x & 0x3) == 0) << 1;
|
||||
x >>= t;
|
||||
x &= 3; /* x = [0 - 3] */
|
||||
r += t; /* r = [0 - 30] and is even */
|
||||
/* return r + ctz(x) */
|
||||
|
||||
/* The branch-less return statement below is equivalent
|
||||
* to the following switch statement:
|
||||
* switch (x)
|
||||
* {
|
||||
* case 0:
|
||||
* return r + 2;
|
||||
* case 2:
|
||||
* return r + 1;
|
||||
* case 1:
|
||||
* case 3:
|
||||
* return r;
|
||||
* }
|
||||
*/
|
||||
return r + ((2 - (x >> 1)) & -((x & 1) == 0));
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
/* ===-- ctzti2.c - Implement __ctzti2 -------------------------------------===
|
||||
*
|
||||
* The LLVM Compiler Infrastructure
|
||||
*
|
||||
* This file is distributed under the University of Illinois Open Source
|
||||
* License. See LICENSE.TXT for details.
|
||||
*
|
||||
* ===----------------------------------------------------------------------===
|
||||
*
|
||||
* This file implements __ctzti2 for the compiler_rt library.
|
||||
*
|
||||
* ===----------------------------------------------------------------------===
|
||||
*/
|
||||
|
||||
#if __x86_64
|
||||
|
||||
#include "int_lib.h"
|
||||
|
||||
/* Returns: the number of trailing 0-bits */
|
||||
|
||||
/* Precondition: a != 0 */
|
||||
|
||||
si_int
|
||||
__ctzti2(ti_int a)
|
||||
{
|
||||
twords x;
|
||||
x.all = a;
|
||||
const di_int f = -(x.low == 0);
|
||||
return __builtin_ctzll((x.high & f) | (x.low & ~f)) +
|
||||
((si_int)f & ((si_int)(sizeof(di_int) * CHAR_BIT)));
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -1,59 +0,0 @@
|
||||
/* ===-- divdc3.c - Implement __divdc3 -------------------------------------===
|
||||
*
|
||||
* The LLVM Compiler Infrastructure
|
||||
*
|
||||
* This file is distributed under the University of Illinois Open Source
|
||||
* License. See LICENSE.TXT for details.
|
||||
*
|
||||
* ===----------------------------------------------------------------------===
|
||||
*
|
||||
* This file implements __divdc3 for the compiler_rt library.
|
||||
*
|
||||
* ===----------------------------------------------------------------------===
|
||||
*/
|
||||
|
||||
#include "int_lib.h"
|
||||
#include <math.h>
|
||||
#include <complex.h>
|
||||
|
||||
/* Returns: the quotient of (a + ib) / (c + id) */
|
||||
|
||||
double _Complex
|
||||
__divdc3(double __a, double __b, double __c, double __d)
|
||||
{
|
||||
int __ilogbw = 0;
|
||||
double __logbw = logb(fmax(fabs(__c), fabs(__d)));
|
||||
if (isfinite(__logbw))
|
||||
{
|
||||
__ilogbw = (int)__logbw;
|
||||
__c = scalbn(__c, -__ilogbw);
|
||||
__d = scalbn(__d, -__ilogbw);
|
||||
}
|
||||
double __denom = __c * __c + __d * __d;
|
||||
double _Complex z;
|
||||
__real__ z = scalbn((__a * __c + __b * __d) / __denom, -__ilogbw);
|
||||
__imag__ z = scalbn((__b * __c - __a * __d) / __denom, -__ilogbw);
|
||||
if (isnan(__real__ z) && isnan(__imag__ z))
|
||||
{
|
||||
if ((__denom == 0.0) && (!isnan(__a) || !isnan(__b)))
|
||||
{
|
||||
__real__ z = copysign(INFINITY, __c) * __a;
|
||||
__imag__ z = copysign(INFINITY, __c) * __b;
|
||||
}
|
||||
else if ((isinf(__a) || isinf(__b)) && isfinite(__c) && isfinite(__d))
|
||||
{
|
||||
__a = copysign(isinf(__a) ? 1.0 : 0.0, __a);
|
||||
__b = copysign(isinf(__b) ? 1.0 : 0.0, __b);
|
||||
__real__ z = INFINITY * (__a * __c + __b * __d);
|
||||
__imag__ z = INFINITY * (__b * __c - __a * __d);
|
||||
}
|
||||
else if (isinf(__logbw) && __logbw > 0.0 && isfinite(__a) && isfinite(__b))
|
||||
{
|
||||
__c = copysign(isinf(__c) ? 1.0 : 0.0, __c);
|
||||
__d = copysign(isinf(__d) ? 1.0 : 0.0, __d);
|
||||
__real__ z = 0.0 * (__a * __c + __b * __d);
|
||||
__imag__ z = 0.0 * (__b * __c - __a * __d);
|
||||
}
|
||||
}
|
||||
return z;
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
/* ===-- divdi3.c - Implement __divdi3 -------------------------------------===
|
||||
*
|
||||
* The LLVM Compiler Infrastructure
|
||||
*
|
||||
* This file is distributed under the University of Illinois Open Source
|
||||
* License. See LICENSE.TXT for details.
|
||||
*
|
||||
* ===----------------------------------------------------------------------===
|
||||
*
|
||||
* This file implements __divdi3 for the compiler_rt library.
|
||||
*
|
||||
* ===----------------------------------------------------------------------===
|
||||
*/
|
||||
|
||||
#include "int_lib.h"
|
||||
|
||||
du_int __udivmoddi4(du_int a, du_int b, du_int* rem);
|
||||
|
||||
/* Returns: a / b */
|
||||
|
||||
di_int
|
||||
__divdi3(di_int a, di_int b)
|
||||
{
|
||||
const int bits_in_dword_m1 = (int)(sizeof(di_int) * CHAR_BIT) - 1;
|
||||
di_int s_a = a >> bits_in_dword_m1; /* s_a = a < 0 ? -1 : 0 */
|
||||
di_int s_b = b >> bits_in_dword_m1; /* s_b = b < 0 ? -1 : 0 */
|
||||
a = (a ^ s_a) - s_a; /* negate if s_a == -1 */
|
||||
b = (b ^ s_b) - s_b; /* negate if s_b == -1 */
|
||||
s_a ^= s_b; /*sign of quotient */
|
||||
return (__udivmoddi4(a, b, (du_int*)0) ^ s_a) - s_a; /* negate if s_a == -1 */
|
||||
}
|
||||
@@ -1,59 +0,0 @@
|
||||
/*===-- divsc3.c - Implement __divsc3 -------------------------------------===
|
||||
*
|
||||
* The LLVM Compiler Infrastructure
|
||||
*
|
||||
* This file is distributed under the University of Illinois Open Source
|
||||
* License. See LICENSE.TXT for details.
|
||||
*
|
||||
* ===----------------------------------------------------------------------===
|
||||
*
|
||||
* This file implements __divsc3 for the compiler_rt library.
|
||||
*
|
||||
*===----------------------------------------------------------------------===
|
||||
*/
|
||||
|
||||
#include "int_lib.h"
|
||||
#include <math.h>
|
||||
#include <complex.h>
|
||||
|
||||
/* Returns: the quotient of (a + ib) / (c + id) */
|
||||
|
||||
float _Complex
|
||||
__divsc3(float __a, float __b, float __c, float __d)
|
||||
{
|
||||
int __ilogbw = 0;
|
||||
float __logbw = logbf(fmaxf(fabsf(__c), fabsf(__d)));
|
||||
if (isfinite(__logbw))
|
||||
{
|
||||
__ilogbw = (int)__logbw;
|
||||
__c = scalbnf(__c, -__ilogbw);
|
||||
__d = scalbnf(__d, -__ilogbw);
|
||||
}
|
||||
float __denom = __c * __c + __d * __d;
|
||||
float _Complex z;
|
||||
__real__ z = scalbnf((__a * __c + __b * __d) / __denom, -__ilogbw);
|
||||
__imag__ z = scalbnf((__b * __c - __a * __d) / __denom, -__ilogbw);
|
||||
if (isnan(__real__ z) && isnan(__imag__ z))
|
||||
{
|
||||
if ((__denom == 0) && (!isnan(__a) || !isnan(__b)))
|
||||
{
|
||||
__real__ z = copysignf(INFINITY, __c) * __a;
|
||||
__imag__ z = copysignf(INFINITY, __c) * __b;
|
||||
}
|
||||
else if ((isinf(__a) || isinf(__b)) && isfinite(__c) && isfinite(__d))
|
||||
{
|
||||
__a = copysignf(isinf(__a) ? 1 : 0, __a);
|
||||
__b = copysignf(isinf(__b) ? 1 : 0, __b);
|
||||
__real__ z = INFINITY * (__a * __c + __b * __d);
|
||||
__imag__ z = INFINITY * (__b * __c - __a * __d);
|
||||
}
|
||||
else if (isinf(__logbw) && __logbw > 0 && isfinite(__a) && isfinite(__b))
|
||||
{
|
||||
__c = copysignf(isinf(__c) ? 1 : 0, __c);
|
||||
__d = copysignf(isinf(__d) ? 1 : 0, __d);
|
||||
__real__ z = 0 * (__a * __c + __b * __d);
|
||||
__imag__ z = 0 * (__b * __c - __a * __d);
|
||||
}
|
||||
}
|
||||
return z;
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
/* ===-- divsi3.c - Implement __divsi3 -------------------------------------===
|
||||
*
|
||||
* The LLVM Compiler Infrastructure
|
||||
*
|
||||
* This file is distributed under the University of Illinois Open Source
|
||||
* License. See LICENSE.TXT for details.
|
||||
*
|
||||
* ===----------------------------------------------------------------------===
|
||||
*
|
||||
* This file implements __divsi3 for the compiler_rt library.
|
||||
*
|
||||
* ===----------------------------------------------------------------------===
|
||||
*/
|
||||
|
||||
#include "int_lib.h"
|
||||
|
||||
su_int __udivsi3(su_int n, su_int d);
|
||||
|
||||
/* Returns: a / b */
|
||||
|
||||
si_int
|
||||
__divsi3(si_int a, si_int b)
|
||||
{
|
||||
const int bits_in_word_m1 = (int)(sizeof(si_int) * CHAR_BIT) - 1;
|
||||
si_int s_a = a >> bits_in_word_m1; /* s_a = a < 0 ? -1 : 0 */
|
||||
si_int s_b = b >> bits_in_word_m1; /* s_b = b < 0 ? -1 : 0 */
|
||||
a = (a ^ s_a) - s_a; /* negate if s_a == -1 */
|
||||
b = (b ^ s_b) - s_b; /* negate if s_b == -1 */
|
||||
s_a ^= s_b; /* sign of quotient */
|
||||
return (__udivsi3(a, b) ^ s_a) - s_a; /* negate if s_a == -1 */
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
/* ===-- divti3.c - Implement __divti3 -------------------------------------===
|
||||
*
|
||||
* The LLVM Compiler Infrastructure
|
||||
*
|
||||
* This file is distributed under the University of Illinois Open Source
|
||||
* License. See LICENSE.TXT for details.
|
||||
*
|
||||
* ===----------------------------------------------------------------------===
|
||||
*
|
||||
* This file implements __divti3 for the compiler_rt library.
|
||||
*
|
||||
* ===----------------------------------------------------------------------===
|
||||
*/
|
||||
|
||||
#if __x86_64
|
||||
|
||||
#include "int_lib.h"
|
||||
|
||||
tu_int __udivmodti4(tu_int a, tu_int b, tu_int* rem);
|
||||
|
||||
/* Returns: a / b */
|
||||
|
||||
ti_int
|
||||
__divti3(ti_int a, ti_int b)
|
||||
{
|
||||
const int bits_in_tword_m1 = (int)(sizeof(ti_int) * CHAR_BIT) - 1;
|
||||
ti_int s_a = a >> bits_in_tword_m1; /* s_a = a < 0 ? -1 : 0 */
|
||||
ti_int s_b = b >> bits_in_tword_m1; /* s_b = b < 0 ? -1 : 0 */
|
||||
a = (a ^ s_a) - s_a; /* negate if s_a == -1 */
|
||||
b = (b ^ s_b) - s_b; /* negate if s_b == -1 */
|
||||
s_a ^= s_b; /* sign of quotient */
|
||||
return (__udivmodti4(a, b, (tu_int*)0) ^ s_a) - s_a; /* negate if s_a == -1 */
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -1,62 +0,0 @@
|
||||
/* ===-- divxc3.c - Implement __divxc3 -------------------------------------===
|
||||
*
|
||||
* The LLVM Compiler Infrastructure
|
||||
*
|
||||
* This file is distributed under the University of Illinois Open Source
|
||||
* License. See LICENSE.TXT for details.
|
||||
*
|
||||
* ===----------------------------------------------------------------------===
|
||||
*
|
||||
* This file implements __divxc3 for the compiler_rt library.
|
||||
*
|
||||
*/
|
||||
|
||||
#if !_ARCH_PPC
|
||||
|
||||
#include "int_lib.h"
|
||||
#include <math.h>
|
||||
#include <complex.h>
|
||||
|
||||
/* Returns: the quotient of (a + ib) / (c + id) */
|
||||
|
||||
long double _Complex
|
||||
__divxc3(long double __a, long double __b, long double __c, long double __d)
|
||||
{
|
||||
int __ilogbw = 0;
|
||||
long double __logbw = logbl(fmaxl(fabsl(__c), fabsl(__d)));
|
||||
if (isfinite(__logbw))
|
||||
{
|
||||
__ilogbw = (int)__logbw;
|
||||
__c = scalbnl(__c, -__ilogbw);
|
||||
__d = scalbnl(__d, -__ilogbw);
|
||||
}
|
||||
long double __denom = __c * __c + __d * __d;
|
||||
long double _Complex z;
|
||||
__real__ z = scalbnl((__a * __c + __b * __d) / __denom, -__ilogbw);
|
||||
__imag__ z = scalbnl((__b * __c - __a * __d) / __denom, -__ilogbw);
|
||||
if (isnan(__real__ z) && isnan(__imag__ z))
|
||||
{
|
||||
if ((__denom == 0) && (!isnan(__a) || !isnan(__b)))
|
||||
{
|
||||
__real__ z = copysignl(INFINITY, __c) * __a;
|
||||
__imag__ z = copysignl(INFINITY, __c) * __b;
|
||||
}
|
||||
else if ((isinf(__a) || isinf(__b)) && isfinite(__c) && isfinite(__d))
|
||||
{
|
||||
__a = copysignl(isinf(__a) ? 1 : 0, __a);
|
||||
__b = copysignl(isinf(__b) ? 1 : 0, __b);
|
||||
__real__ z = INFINITY * (__a * __c + __b * __d);
|
||||
__imag__ z = INFINITY * (__b * __c - __a * __d);
|
||||
}
|
||||
else if (isinf(__logbw) && __logbw > 0 && isfinite(__a) && isfinite(__b))
|
||||
{
|
||||
__c = copysignl(isinf(__c) ? 1 : 0, __c);
|
||||
__d = copysignl(isinf(__d) ? 1 : 0, __d);
|
||||
__real__ z = 0 * (__a * __c + __b * __d);
|
||||
__imag__ z = 0 * (__b * __c - __a * __d);
|
||||
}
|
||||
}
|
||||
return z;
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -1,53 +0,0 @@
|
||||
/* ===-- enable_execute_stack.c - Implement __enable_execute_stack ---------===
|
||||
*
|
||||
* The LLVM Compiler Infrastructure
|
||||
*
|
||||
* This file is distributed under the University of Illinois Open Source
|
||||
* License. See LICENSE.TXT for details.
|
||||
*
|
||||
* ===----------------------------------------------------------------------===
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include <sys/mman.h>
|
||||
|
||||
/* #include "config.h"
|
||||
* FIXME: CMake - include when cmake system is ready.
|
||||
* Remove #define HAVE_SYSCONF 1 line.
|
||||
*/
|
||||
#define HAVE_SYSCONF 1
|
||||
|
||||
#ifndef __APPLE__
|
||||
#include <unistd.h>
|
||||
#endif /* __APPLE__ */
|
||||
|
||||
|
||||
/*
|
||||
* The compiler generates calls to __enable_execute_stack() when creating
|
||||
* trampoline functions on the stack for use with nested functions.
|
||||
* It is expected to mark the page(s) containing the address
|
||||
* and the next 48 bytes as executable. Since the stack is normally rw-
|
||||
* that means changing the protection on those page(s) to rwx.
|
||||
*/
|
||||
|
||||
void __enable_execute_stack(void* addr)
|
||||
{
|
||||
|
||||
#if __APPLE__
|
||||
/* On Darwin, pagesize is always 4096 bytes */
|
||||
const uintptr_t pageSize = 4096;
|
||||
#elif !defined(HAVE_SYSCONF)
|
||||
#error "HAVE_SYSCONF not defined! See enable_execute_stack.c"
|
||||
#else
|
||||
const uintptr_t pageSize = sysconf(_SC_PAGESIZE);
|
||||
#endif /* __APPLE__ */
|
||||
|
||||
const uintptr_t pageAlignMask = ~(pageSize-1);
|
||||
uintptr_t p = (uintptr_t)addr;
|
||||
unsigned char* startPage = (unsigned char*)(p & pageAlignMask);
|
||||
unsigned char* endPage = (unsigned char*)((p+48+pageSize) & pageAlignMask);
|
||||
size_t length = endPage - startPage;
|
||||
(void) mprotect((void *)startPage, length, PROT_READ | PROT_WRITE | PROT_EXEC);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,94 +0,0 @@
|
||||
/* ===-- endianness.h - configuration header for libgcc replacement --------===
|
||||
*
|
||||
* The LLVM Compiler Infrastructure
|
||||
*
|
||||
* This file is distributed under the University of Illinois Open Source
|
||||
* License. See LICENSE.TXT for details.
|
||||
*
|
||||
* ===----------------------------------------------------------------------===
|
||||
*
|
||||
* This file is a configuration header for libgcc replacement.
|
||||
* This file is not part of the interface of this library.
|
||||
*
|
||||
* ===----------------------------------------------------------------------===
|
||||
*/
|
||||
|
||||
#ifndef ENDIANNESS_H
|
||||
#define ENDIANNESS_H
|
||||
|
||||
/*
|
||||
* Known limitations:
|
||||
* Middle endian systems are not handled currently.
|
||||
*/
|
||||
|
||||
#if defined(__SVR4) && defined(__sun)
|
||||
#include <sys/byteorder.h>
|
||||
|
||||
#if _BYTE_ORDER == _BIG_ENDIAN
|
||||
#define _YUGA_LITTLE_ENDIAN 0
|
||||
#define _YUGA_BIG_ENDIAN 1
|
||||
#elif _BYTE_ORDER == _LITTLE_ENDIAN
|
||||
#define _YUGA_LITTLE_ENDIAN 1
|
||||
#define _YUGA_BIG_ENDIAN 0
|
||||
#endif /* _BYTE_ORDER */
|
||||
|
||||
#endif /* Solaris and AuroraUX. */
|
||||
|
||||
/* .. */
|
||||
|
||||
#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__DragonflyBSD__)
|
||||
#include <sys/endian.h>
|
||||
|
||||
#if _BYTE_ORDER == _BIG_ENDIAN
|
||||
#define _YUGA_LITTLE_ENDIAN 0
|
||||
#define _YUGA_BIG_ENDIAN 1
|
||||
#elif _BYTE_ORDER == _LITTLE_ENDIAN
|
||||
#define _YUGA_LITTLE_ENDIAN 1
|
||||
#define _YUGA_BIG_ENDIAN 0
|
||||
#endif /* _BYTE_ORDER */
|
||||
|
||||
#endif /* *BSD */
|
||||
|
||||
/* .. */
|
||||
|
||||
/* Mac OSX has __BIG_ENDIAN__ or __LITTLE_ENDIAN__ automatically set by the compiler (at least with GCC) */
|
||||
#if defined(__APPLE__) && defined(__MACH__) || defined(__ellcc__ )
|
||||
|
||||
#ifdef __BIG_ENDIAN__
|
||||
#if __BIG_ENDIAN__
|
||||
#define _YUGA_LITTLE_ENDIAN 0
|
||||
#define _YUGA_BIG_ENDIAN 1
|
||||
#endif
|
||||
#endif /* __BIG_ENDIAN__ */
|
||||
|
||||
#ifdef __LITTLE_ENDIAN__
|
||||
#if __LITTLE_ENDIAN__
|
||||
#define _YUGA_LITTLE_ENDIAN 1
|
||||
#define _YUGA_BIG_ENDIAN 0
|
||||
#endif
|
||||
#endif /* __LITTLE_ENDIAN__ */
|
||||
|
||||
#endif /* Mac OSX */
|
||||
|
||||
/* .. */
|
||||
|
||||
#if defined(__linux__)
|
||||
#include <endian.h>
|
||||
|
||||
#if __BYTE_ORDER == __BIG_ENDIAN
|
||||
#define _YUGA_LITTLE_ENDIAN 0
|
||||
#define _YUGA_BIG_ENDIAN 1
|
||||
#elif __BYTE_ORDER == __LITTLE_ENDIAN
|
||||
#define _YUGA_LITTLE_ENDIAN 1
|
||||
#define _YUGA_BIG_ENDIAN 0
|
||||
#endif /* __BYTE_ORDER */
|
||||
|
||||
#endif /* GNU/Linux */
|
||||
|
||||
/* . */
|
||||
|
||||
#if !defined(_YUGA_LITTLE_ENDIAN) || !defined(_YUGA_BIG_ENDIAN)
|
||||
#error Unable to determine endian
|
||||
#endif /* Check we found an endianness correctly. */
|
||||
|
||||
#endif /* ENDIANNESS_H */
|
||||
@@ -1,32 +0,0 @@
|
||||
/* ===---------- eprintf.c - Implements __eprintf --------------------------===
|
||||
*
|
||||
* The LLVM Compiler Infrastructure
|
||||
*
|
||||
* This file is distributed under the University of Illinois Open Source
|
||||
* License. See LICENSE.TXT for details.
|
||||
*
|
||||
* ===----------------------------------------------------------------------===
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
|
||||
/*
|
||||
* __eprintf() was used in an old version of <assert.h>.
|
||||
* It can eventually go away, but it is needed when linking
|
||||
* .o files built with the old <assert.h>.
|
||||
*
|
||||
* It should never be exported from a dylib, so it is marked
|
||||
* visibility hidden.
|
||||
*/
|
||||
__attribute__((visibility("hidden")))
|
||||
void __eprintf(const char* format, const char* assertion_expression,
|
||||
const char* line, const char* file)
|
||||
{
|
||||
fprintf(stderr, format, assertion_expression, line, file);
|
||||
fflush(stderr);
|
||||
abort();
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
/* ===-- ffsdi2.c - Implement __ffsdi2 -------------------------------------===
|
||||
*
|
||||
* The LLVM Compiler Infrastructure
|
||||
*
|
||||
* This file is distributed under the University of Illinois Open Source
|
||||
* License. See LICENSE.TXT for details.
|
||||
*
|
||||
* ===----------------------------------------------------------------------===
|
||||
*
|
||||
* This file implements __ffsdi2 for the compiler_rt library.
|
||||
*
|
||||
* ===----------------------------------------------------------------------===
|
||||
*/
|
||||
|
||||
#include "int_lib.h"
|
||||
|
||||
/* Returns: the index of the least significant 1-bit in a, or
|
||||
* the value zero if a is zero. The least significant bit is index one.
|
||||
*/
|
||||
|
||||
si_int
|
||||
__ffsdi2(di_int a)
|
||||
{
|
||||
dwords x;
|
||||
x.all = a;
|
||||
if (x.s.low == 0)
|
||||
{
|
||||
if (x.s.high == 0)
|
||||
return 0;
|
||||
return __builtin_ctz(x.s.high) + (1 + sizeof(si_int) * CHAR_BIT);
|
||||
}
|
||||
return __builtin_ctz(x.s.low) + 1;
|
||||
}
|
||||
@@ -1,37 +0,0 @@
|
||||
/* ===-- ffsti2.c - Implement __ffsti2 -------------------------------------===
|
||||
*
|
||||
* The LLVM Compiler Infrastructure
|
||||
*
|
||||
* This file is distributed under the University of Illinois Open Source
|
||||
* License. See LICENSE.TXT for details.
|
||||
*
|
||||
* ===----------------------------------------------------------------------===
|
||||
*
|
||||
* This file implements __ffsti2 for the compiler_rt library.
|
||||
*
|
||||
* ===----------------------------------------------------------------------===
|
||||
*/
|
||||
|
||||
#if __x86_64
|
||||
|
||||
#include "int_lib.h"
|
||||
|
||||
/* Returns: the index of the least significant 1-bit in a, or
|
||||
* the value zero if a is zero. The least significant bit is index one.
|
||||
*/
|
||||
|
||||
si_int
|
||||
__ffsti2(ti_int a)
|
||||
{
|
||||
twords x;
|
||||
x.all = a;
|
||||
if (x.low == 0)
|
||||
{
|
||||
if (x.high == 0)
|
||||
return 0;
|
||||
return __builtin_ctzll(x.high) + (1 + sizeof(di_int) * CHAR_BIT);
|
||||
}
|
||||
return __builtin_ctzll(x.low) + 1;
|
||||
}
|
||||
|
||||
#endif /* __x86_64 */
|
||||
@@ -1,43 +0,0 @@
|
||||
/* ===-- fixdfdi.c - Implement __fixdfdi -----------------------------------===
|
||||
*
|
||||
* The LLVM Compiler Infrastructure
|
||||
*
|
||||
* This file is distributed under the University of Illinois Open Source
|
||||
* License. See LICENSE.TXT for details.
|
||||
*
|
||||
* ===----------------------------------------------------------------------===
|
||||
*
|
||||
* This file implements __fixdfdi for the compiler_rt library.
|
||||
*
|
||||
* ===----------------------------------------------------------------------===
|
||||
*/
|
||||
|
||||
#include "int_lib.h"
|
||||
|
||||
/* Returns: convert a to a signed long long, rounding toward zero. */
|
||||
|
||||
/* Assumption: double is a IEEE 64 bit floating point type
|
||||
* su_int is a 32 bit integral type
|
||||
* value in double is representable in di_int (no range checking performed)
|
||||
*/
|
||||
|
||||
/* seee eeee eeee mmmm mmmm mmmm mmmm mmmm | mmmm mmmm mmmm mmmm mmmm mmmm mmmm mmmm */
|
||||
|
||||
di_int
|
||||
__fixdfdi(double a)
|
||||
{
|
||||
double_bits fb;
|
||||
fb.f = a;
|
||||
int e = ((fb.u.s.high & 0x7FF00000) >> 20) - 1023;
|
||||
if (e < 0)
|
||||
return 0;
|
||||
di_int s = (si_int)(fb.u.s.high & 0x80000000) >> 31;
|
||||
dwords r;
|
||||
r.s.high = (fb.u.s.high & 0x000FFFFF) | 0x00100000;
|
||||
r.s.low = fb.u.s.low;
|
||||
if (e > 52)
|
||||
r.all <<= (e - 52);
|
||||
else
|
||||
r.all >>= (52 - e);
|
||||
return (r.all ^ s) - s;
|
||||
}
|
||||
@@ -1,45 +0,0 @@
|
||||
/* ===-- fixdfti.c - Implement __fixdfti -----------------------------------===
|
||||
*
|
||||
* The LLVM Compiler Infrastructure
|
||||
*
|
||||
* This file is distributed under the University of Illinois Open Source
|
||||
* License. See LICENSE.TXT for details.
|
||||
*
|
||||
* ===----------------------------------------------------------------------===
|
||||
*
|
||||
* This file implements __fixdfti for the compiler_rt library.
|
||||
*
|
||||
* ===----------------------------------------------------------------------===
|
||||
*/
|
||||
|
||||
#if __x86_64
|
||||
|
||||
#include "int_lib.h"
|
||||
|
||||
/* Returns: convert a to a signed long long, rounding toward zero. */
|
||||
|
||||
/* Assumption: double is a IEEE 64 bit floating point type
|
||||
* su_int is a 32 bit integral type
|
||||
* value in double is representable in ti_int (no range checking performed)
|
||||
*/
|
||||
|
||||
/* seee eeee eeee mmmm mmmm mmmm mmmm mmmm | mmmm mmmm mmmm mmmm mmmm mmmm mmmm mmmm */
|
||||
|
||||
ti_int
|
||||
__fixdfti(double a)
|
||||
{
|
||||
double_bits fb;
|
||||
fb.f = a;
|
||||
int e = ((fb.u.high & 0x7FF00000) >> 20) - 1023;
|
||||
if (e < 0)
|
||||
return 0;
|
||||
ti_int s = (si_int)(fb.u.high & 0x80000000) >> 31;
|
||||
ti_int r = 0x0010000000000000uLL | (0x000FFFFFFFFFFFFFuLL & fb.u.all);
|
||||
if (e > 52)
|
||||
r <<= (e - 52);
|
||||
else
|
||||
r >>= (52 - e);
|
||||
return (r ^ s) - s;
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -1,41 +0,0 @@
|
||||
/* ===-- fixsfdi.c - Implement __fixsfdi -----------------------------------===
|
||||
*
|
||||
* The LLVM Compiler Infrastructure
|
||||
*
|
||||
* This file is distributed under the University of Illinois Open Source
|
||||
* License. See LICENSE.TXT for details.
|
||||
*
|
||||
* ===----------------------------------------------------------------------===
|
||||
*
|
||||
* This file implements __fixsfdi for the compiler_rt library.
|
||||
*
|
||||
* ===----------------------------------------------------------------------===
|
||||
*/
|
||||
|
||||
#include "int_lib.h"
|
||||
|
||||
/* Returns: convert a to a signed long long, rounding toward zero. */
|
||||
|
||||
/* Assumption: float is a IEEE 32 bit floating point type
|
||||
* su_int is a 32 bit integral type
|
||||
* value in float is representable in di_int (no range checking performed)
|
||||
*/
|
||||
|
||||
/* seee eeee emmm mmmm mmmm mmmm mmmm mmmm */
|
||||
|
||||
di_int
|
||||
__fixsfdi(float a)
|
||||
{
|
||||
float_bits fb;
|
||||
fb.f = a;
|
||||
int e = ((fb.u & 0x7F800000) >> 23) - 127;
|
||||
if (e < 0)
|
||||
return 0;
|
||||
di_int s = (si_int)(fb.u & 0x80000000) >> 31;
|
||||
di_int r = (fb.u & 0x007FFFFF) | 0x00800000;
|
||||
if (e > 23)
|
||||
r <<= (e - 23);
|
||||
else
|
||||
r >>= (23 - e);
|
||||
return (r ^ s) - s;
|
||||
}
|
||||
@@ -1,45 +0,0 @@
|
||||
/* ===-- fixsfti.c - Implement __fixsfti -----------------------------------===
|
||||
*
|
||||
* The LLVM Compiler Infrastructure
|
||||
*
|
||||
* This file is distributed under the University of Illinois Open Source
|
||||
* License. See LICENSE.TXT for details.
|
||||
*
|
||||
* ===----------------------------------------------------------------------===
|
||||
*
|
||||
* This file implements __fixsfti for the compiler_rt library.
|
||||
*
|
||||
* ===----------------------------------------------------------------------===
|
||||
*/
|
||||
|
||||
#if __x86_64
|
||||
|
||||
#include "int_lib.h"
|
||||
|
||||
/* Returns: convert a to a signed long long, rounding toward zero. */
|
||||
|
||||
/* Assumption: float is a IEEE 32 bit floating point type
|
||||
* su_int is a 32 bit integral type
|
||||
* value in float is representable in ti_int (no range checking performed)
|
||||
*/
|
||||
|
||||
/* seee eeee emmm mmmm mmmm mmmm mmmm mmmm */
|
||||
|
||||
ti_int
|
||||
__fixsfti(float a)
|
||||
{
|
||||
float_bits fb;
|
||||
fb.f = a;
|
||||
int e = ((fb.u & 0x7F800000) >> 23) - 127;
|
||||
if (e < 0)
|
||||
return 0;
|
||||
ti_int s = (si_int)(fb.u & 0x80000000) >> 31;
|
||||
ti_int r = (fb.u & 0x007FFFFF) | 0x00800000;
|
||||
if (e > 23)
|
||||
r <<= (e - 23);
|
||||
else
|
||||
r >>= (23 - e);
|
||||
return (r ^ s) - s;
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -1,45 +0,0 @@
|
||||
/* ===-- fixunsdfdi.c - Implement __fixunsdfdi -----------------------------===
|
||||
*
|
||||
* The LLVM Compiler Infrastructure
|
||||
*
|
||||
* This file is distributed under the University of Illinois Open Source
|
||||
* License. See LICENSE.TXT for details.
|
||||
*
|
||||
* ===----------------------------------------------------------------------===
|
||||
*
|
||||
* This file implements __fixunsdfdi for the compiler_rt library.
|
||||
*
|
||||
* ===----------------------------------------------------------------------===
|
||||
*/
|
||||
|
||||
#include "int_lib.h"
|
||||
|
||||
/* Returns: convert a to a unsigned long long, rounding toward zero.
|
||||
* Negative values all become zero.
|
||||
*/
|
||||
|
||||
/* Assumption: double is a IEEE 64 bit floating point type
|
||||
* du_int is a 64 bit integral type
|
||||
* value in double is representable in du_int or is negative
|
||||
* (no range checking performed)
|
||||
*/
|
||||
|
||||
/* seee eeee eeee mmmm mmmm mmmm mmmm mmmm | mmmm mmmm mmmm mmmm mmmm mmmm mmmm mmmm */
|
||||
|
||||
du_int
|
||||
__fixunsdfdi(double a)
|
||||
{
|
||||
double_bits fb;
|
||||
fb.f = a;
|
||||
int e = ((fb.u.s.high & 0x7FF00000) >> 20) - 1023;
|
||||
if (e < 0 || (fb.u.s.high & 0x80000000))
|
||||
return 0;
|
||||
udwords r;
|
||||
r.s.high = (fb.u.s.high & 0x000FFFFF) | 0x00100000;
|
||||
r.s.low = fb.u.s.low;
|
||||
if (e > 52)
|
||||
r.all <<= (e - 52);
|
||||
else
|
||||
r.all >>= (52 - e);
|
||||
return r.all;
|
||||
}
|
||||
@@ -1,42 +0,0 @@
|
||||
/* ===-- fixunsdfsi.c - Implement __fixunsdfsi -----------------------------===
|
||||
*
|
||||
* The LLVM Compiler Infrastructure
|
||||
*
|
||||
* This file is distributed under the University of Illinois Open Source
|
||||
* License. See LICENSE.TXT for details.
|
||||
*
|
||||
* ===----------------------------------------------------------------------===
|
||||
*
|
||||
* This file implements __fixunsdfsi for the compiler_rt library.
|
||||
*
|
||||
* ===----------------------------------------------------------------------===
|
||||
*/
|
||||
|
||||
#include "int_lib.h"
|
||||
|
||||
/* Returns: convert a to a unsigned int, rounding toward zero.
|
||||
* Negative values all become zero.
|
||||
*/
|
||||
|
||||
/* Assumption: double is a IEEE 64 bit floating point type
|
||||
* su_int is a 32 bit integral type
|
||||
* value in double is representable in su_int or is negative
|
||||
* (no range checking performed)
|
||||
*/
|
||||
|
||||
/* seee eeee eeee mmmm mmmm mmmm mmmm mmmm | mmmm mmmm mmmm mmmm mmmm mmmm mmmm mmmm */
|
||||
|
||||
su_int
|
||||
__fixunsdfsi(double a)
|
||||
{
|
||||
double_bits fb;
|
||||
fb.f = a;
|
||||
int e = ((fb.u.s.high & 0x7FF00000) >> 20) - 1023;
|
||||
if (e < 0 || (fb.u.s.high & 0x80000000))
|
||||
return 0;
|
||||
return (
|
||||
0x80000000u |
|
||||
((fb.u.s.high & 0x000FFFFF) << 11) |
|
||||
(fb.u.s.low >> 21)
|
||||
) >> (31 - e);
|
||||
}
|
||||
@@ -1,47 +0,0 @@
|
||||
/* ===-- fixunsdfti.c - Implement __fixunsdfti -----------------------------===
|
||||
*
|
||||
* The LLVM Compiler Infrastructure
|
||||
*
|
||||
* This file is distributed under the University of Illinois Open Source
|
||||
* License. See LICENSE.TXT for details.
|
||||
*
|
||||
* ===----------------------------------------------------------------------===
|
||||
*
|
||||
* This file implements __fixunsdfti for the compiler_rt library.
|
||||
*
|
||||
* ===----------------------------------------------------------------------===
|
||||
*/
|
||||
|
||||
#if __x86_64
|
||||
|
||||
#include "int_lib.h"
|
||||
|
||||
/* Returns: convert a to a unsigned long long, rounding toward zero.
|
||||
* Negative values all become zero.
|
||||
*/
|
||||
|
||||
/* Assumption: double is a IEEE 64 bit floating point type
|
||||
* tu_int is a 64 bit integral type
|
||||
* value in double is representable in tu_int or is negative
|
||||
* (no range checking performed)
|
||||
*/
|
||||
|
||||
/* seee eeee eeee mmmm mmmm mmmm mmmm mmmm | mmmm mmmm mmmm mmmm mmmm mmmm mmmm mmmm */
|
||||
|
||||
tu_int
|
||||
__fixunsdfti(double a)
|
||||
{
|
||||
double_bits fb;
|
||||
fb.f = a;
|
||||
int e = ((fb.u.high & 0x7FF00000) >> 20) - 1023;
|
||||
if (e < 0 || (fb.u.high & 0x80000000))
|
||||
return 0;
|
||||
tu_int r = 0x0010000000000000uLL | (fb.u.all & 0x000FFFFFFFFFFFFFuLL);
|
||||
if (e > 52)
|
||||
r <<= (e - 52);
|
||||
else
|
||||
r >>= (52 - e);
|
||||
return r;
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -1,43 +0,0 @@
|
||||
/* ===-- fixunssfdi.c - Implement __fixunssfdi -----------------------------===
|
||||
*
|
||||
* The LLVM Compiler Infrastructure
|
||||
*
|
||||
* This file is distributed under the University of Illinois Open Source
|
||||
* License. See LICENSE.TXT for details.
|
||||
*
|
||||
* ===----------------------------------------------------------------------===
|
||||
*
|
||||
* This file implements __fixunssfdi for the compiler_rt library.
|
||||
*
|
||||
* ===----------------------------------------------------------------------===
|
||||
*/
|
||||
|
||||
#include "int_lib.h"
|
||||
|
||||
/* Returns: convert a to a unsigned long long, rounding toward zero.
|
||||
* Negative values all become zero.
|
||||
*/
|
||||
|
||||
/* Assumption: float is a IEEE 32 bit floating point type
|
||||
* du_int is a 64 bit integral type
|
||||
* value in float is representable in du_int or is negative
|
||||
* (no range checking performed)
|
||||
*/
|
||||
|
||||
/* seee eeee emmm mmmm mmmm mmmm mmmm mmmm */
|
||||
|
||||
du_int
|
||||
__fixunssfdi(float a)
|
||||
{
|
||||
float_bits fb;
|
||||
fb.f = a;
|
||||
int e = ((fb.u & 0x7F800000) >> 23) - 127;
|
||||
if (e < 0 || (fb.u & 0x80000000))
|
||||
return 0;
|
||||
du_int r = (fb.u & 0x007FFFFF) | 0x00800000;
|
||||
if (e > 23)
|
||||
r <<= (e - 23);
|
||||
else
|
||||
r >>= (23 - e);
|
||||
return r;
|
||||
}
|
||||
@@ -1,43 +0,0 @@
|
||||
/* ===-- fixunssfsi.c - Implement __fixunssfsi -----------------------------===
|
||||
*
|
||||
* The LLVM Compiler Infrastructure
|
||||
*
|
||||
* This file is distributed under the University of Illinois Open Source
|
||||
* License. See LICENSE.TXT for details.
|
||||
*
|
||||
* ===----------------------------------------------------------------------===
|
||||
*
|
||||
* This file implements __fixunssfsi for the compiler_rt library.
|
||||
*
|
||||
* ===----------------------------------------------------------------------===
|
||||
*/
|
||||
|
||||
#include "int_lib.h"
|
||||
|
||||
/* Returns: convert a to a unsigned int, rounding toward zero.
|
||||
* Negative values all become zero.
|
||||
*/
|
||||
|
||||
/* Assumption: float is a IEEE 32 bit floating point type
|
||||
* su_int is a 32 bit integral type
|
||||
* value in float is representable in su_int or is negative
|
||||
* (no range checking performed)
|
||||
*/
|
||||
|
||||
/* seee eeee emmm mmmm mmmm mmmm mmmm mmmm */
|
||||
|
||||
su_int
|
||||
__fixunssfsi(float a)
|
||||
{
|
||||
float_bits fb;
|
||||
fb.f = a;
|
||||
int e = ((fb.u & 0x7F800000) >> 23) - 127;
|
||||
if (e < 0 || (fb.u & 0x80000000))
|
||||
return 0;
|
||||
su_int r = (fb.u & 0x007FFFFF) | 0x00800000;
|
||||
if (e > 23)
|
||||
r <<= (e - 23);
|
||||
else
|
||||
r >>= (23 - e);
|
||||
return r;
|
||||
}
|
||||
@@ -1,47 +0,0 @@
|
||||
/* ===-- fixunssfti.c - Implement __fixunssfti -----------------------------===
|
||||
*
|
||||
* The LLVM Compiler Infrastructure
|
||||
*
|
||||
* This file is distributed under the University of Illinois Open Source
|
||||
* License. See LICENSE.TXT for details.
|
||||
*
|
||||
* ===----------------------------------------------------------------------===
|
||||
*
|
||||
* This file implements __fixunssfti for the compiler_rt library.
|
||||
*
|
||||
* ===----------------------------------------------------------------------===
|
||||
*/
|
||||
|
||||
#if __x86_64
|
||||
|
||||
#include "int_lib.h"
|
||||
|
||||
/* Returns: convert a to a unsigned long long, rounding toward zero.
|
||||
* Negative values all become zero.
|
||||
*/
|
||||
|
||||
/* Assumption: float is a IEEE 32 bit floating point type
|
||||
* tu_int is a 64 bit integral type
|
||||
* value in float is representable in tu_int or is negative
|
||||
* (no range checking performed)
|
||||
*/
|
||||
|
||||
/* seee eeee emmm mmmm mmmm mmmm mmmm mmmm */
|
||||
|
||||
tu_int
|
||||
__fixunssfti(float a)
|
||||
{
|
||||
float_bits fb;
|
||||
fb.f = a;
|
||||
int e = ((fb.u & 0x7F800000) >> 23) - 127;
|
||||
if (e < 0 || (fb.u & 0x80000000))
|
||||
return 0;
|
||||
tu_int r = (fb.u & 0x007FFFFF) | 0x00800000;
|
||||
if (e > 23)
|
||||
r <<= (e - 23);
|
||||
else
|
||||
r >>= (23 - e);
|
||||
return r;
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -1,44 +0,0 @@
|
||||
/* ===-- fixunsxfdi.c - Implement __fixunsxfdi -----------------------------===
|
||||
*
|
||||
* The LLVM Compiler Infrastructure
|
||||
*
|
||||
* This file is distributed under the University of Illinois Open Source
|
||||
* License. See LICENSE.TXT for details.
|
||||
*
|
||||
* ===----------------------------------------------------------------------===
|
||||
*
|
||||
* This file implements __fixunsxfdi for the compiler_rt library.
|
||||
*
|
||||
* ===----------------------------------------------------------------------===
|
||||
*/
|
||||
|
||||
#if !_ARCH_PPC
|
||||
|
||||
#include "int_lib.h"
|
||||
|
||||
/* Returns: convert a to a unsigned long long, rounding toward zero.
|
||||
* Negative values all become zero.
|
||||
*/
|
||||
|
||||
/* Assumption: long double is an intel 80 bit floating point type padded with 6 bytes
|
||||
* du_int is a 64 bit integral type
|
||||
* value in long double is representable in du_int or is negative
|
||||
* (no range checking performed)
|
||||
*/
|
||||
|
||||
/* gggg gggg gggg gggg gggg gggg gggg gggg | gggg gggg gggg gggg seee eeee eeee eeee |
|
||||
* 1mmm mmmm mmmm mmmm mmmm mmmm mmmm mmmm | mmmm mmmm mmmm mmmm mmmm mmmm mmmm mmmm
|
||||
*/
|
||||
|
||||
du_int
|
||||
__fixunsxfdi(long double a)
|
||||
{
|
||||
long_double_bits fb;
|
||||
fb.f = a;
|
||||
int e = (fb.u.high.s.low & 0x00007FFF) - 16383;
|
||||
if (e < 0 || (fb.u.high.s.low & 0x00008000))
|
||||
return 0;
|
||||
return fb.u.low.all >> (63 - e);
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -1,44 +0,0 @@
|
||||
/* ===-- fixunsxfsi.c - Implement __fixunsxfsi -----------------------------===
|
||||
*
|
||||
* The LLVM Compiler Infrastructure
|
||||
*
|
||||
* This file is distributed under the University of Illinois Open Source
|
||||
* License. See LICENSE.TXT for details.
|
||||
*
|
||||
* ===----------------------------------------------------------------------===
|
||||
*
|
||||
* This file implements __fixunsxfsi for the compiler_rt library.
|
||||
*
|
||||
* ===----------------------------------------------------------------------===
|
||||
*/
|
||||
|
||||
#if !_ARCH_PPC
|
||||
|
||||
#include "int_lib.h"
|
||||
|
||||
/* Returns: convert a to a unsigned int, rounding toward zero.
|
||||
* Negative values all become zero.
|
||||
*/
|
||||
|
||||
/* Assumption: long double is an intel 80 bit floating point type padded with 6 bytes
|
||||
* su_int is a 32 bit integral type
|
||||
* value in long double is representable in su_int or is negative
|
||||
* (no range checking performed)
|
||||
*/
|
||||
|
||||
/* gggg gggg gggg gggg gggg gggg gggg gggg | gggg gggg gggg gggg seee eeee eeee eeee |
|
||||
* 1mmm mmmm mmmm mmmm mmmm mmmm mmmm mmmm | mmmm mmmm mmmm mmmm mmmm mmmm mmmm mmmm
|
||||
*/
|
||||
|
||||
su_int
|
||||
__fixunsxfsi(long double a)
|
||||
{
|
||||
long_double_bits fb;
|
||||
fb.f = a;
|
||||
int e = (fb.u.high.s.low & 0x00007FFF) - 16383;
|
||||
if (e < 0 || (fb.u.high.s.low & 0x00008000))
|
||||
return 0;
|
||||
return fb.u.low.s.high >> (31 - e);
|
||||
}
|
||||
|
||||
#endif /* !_ARCH_PPC */
|
||||
@@ -1,49 +0,0 @@
|
||||
/* ===-- fixunsxfti.c - Implement __fixunsxfti -----------------------------===
|
||||
*
|
||||
* The LLVM Compiler Infrastructure
|
||||
*
|
||||
* This file is distributed under the University of Illinois Open Source
|
||||
* License. See LICENSE.TXT for details.
|
||||
*
|
||||
* ===----------------------------------------------------------------------===
|
||||
*
|
||||
* This file implements __fixunsxfti for the compiler_rt library.
|
||||
*
|
||||
* ===----------------------------------------------------------------------===
|
||||
*/
|
||||
|
||||
#if __x86_64
|
||||
|
||||
#include "int_lib.h"
|
||||
|
||||
/* Returns: convert a to a unsigned long long, rounding toward zero.
|
||||
* Negative values all become zero.
|
||||
*/
|
||||
|
||||
/* Assumption: long double is an intel 80 bit floating point type padded with 6 bytes
|
||||
* tu_int is a 64 bit integral type
|
||||
* value in long double is representable in tu_int or is negative
|
||||
* (no range checking performed)
|
||||
*/
|
||||
|
||||
/* gggg gggg gggg gggg gggg gggg gggg gggg | gggg gggg gggg gggg seee eeee eeee eeee |
|
||||
* 1mmm mmmm mmmm mmmm mmmm mmmm mmmm mmmm | mmmm mmmm mmmm mmmm mmmm mmmm mmmm mmmm
|
||||
*/
|
||||
|
||||
tu_int
|
||||
__fixunsxfti(long double a)
|
||||
{
|
||||
long_double_bits fb;
|
||||
fb.f = a;
|
||||
int e = (fb.u.high.low & 0x00007FFF) - 16383;
|
||||
if (e < 0 || (fb.u.high.low & 0x00008000))
|
||||
return 0;
|
||||
tu_int r = fb.u.low.all;
|
||||
if (e > 63)
|
||||
r <<= (e - 63);
|
||||
else
|
||||
r >>= (63 - e);
|
||||
return r;
|
||||
}
|
||||
|
||||
#endif
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user